It is very small that my icon Image in drop-down of combobox.
This problem is happening on Mac.
There was no problem on Windows.
I tried various methods, but I could not solve it.
Please tell me what is wrong.
Simplify:
QComboBox* combobox = new QComboBox(ui.parentWidget);
combobox->setStyleSheet("background-color: white;");
combobox->setIconSize(QSize(WIDTH, HEIGHT));
QString name = "testImage";
QString path = "~/testImage";
combobox->addItem(QIcon(path), "", name);
setStyleSheet() may be bad, but it couldn't be fixed by rewriting.
List of things to try:
enlarge the image itself
write stylesheet width, min-width, implicitWidth and fillmode
setSizePolicy()
setSizeAdjustPolicy()
setPalette()
setSize() for pixmap
Related
So this is really frustrating... on the mymaths website: https://www.mymaths.co.uk/, there's an image of a primary school child on a computer with this image address: https://www.mymaths.co.uk/assets/images/big/primary-school-photo-2.jpg.
I've tried so many things, but I can't seem to replace it.
Say I wanted to replace it with a picture of a hamburger, with this address: https://images.ctfassets.net/sd2voc54sjgs/5L6livQvCw28S04IUSAcm6/6482ea1819e86be1b4f7e85bfbbfe9a6/Blog_Header_Hamburger_History_Option.png?fm=jpg&q=80&fl=progressive&w=1100.
So far I've tried lots of threads, but this image seems to be different from images on other websites, which is why my code isn't working on it:
var images3 = document.getElementsByTagName ("img");
var i3=0;
while(i3<images3.length)
{
if(images[i3].src == "https://www.mymaths.co.uk/assets/images/big/primary-school-photo-2.jpg")
{
images[i3].src = "https://images.ctfassets.net/sd2voc54sjgs/5L6livQvCw28S04IUSAcm6/6482ea1819e86be1b4f7e85bfbbfe9a6/Blog_Header_Hamburger_History_Option.png?fm=jpg&q=80&fl=progressive&w=1100";
}
i3=i3+1;
}
Can somebody help me please? Thank you.
Well, this was new for me too. Apparently, the <picture> tag is not just a wrapper - it's a smarter version of <img>.
It allows to chose different URLs for the image tag depending on screen size and type. For example, try to do this in developper tools:
I replaced srcset for the <source> that has (max-width: 767px), which means it is active when browser window is smaller than 767px. Now if you resize browser window to make it smaller, at some point the original image will be raplaced with burger image.
So what you want to do is to replace all <source>'s srcset. This worked for me:
// Limit the list of omages on those that are under `<picture>` tag
const images = document.querySelectorAll("picture img, picture source");
// RegExp to check if we want to replace the URL
const replaceChecker = /primary-school-photo-2\.jpg$/i;
// The replacement URL
const replaceWith = "https://images.ctfassets.net/sd2voc54sjgs/5L6livQvCw28S04IUSAcm6/6482ea1819e86be1b4f7e85bfbbfe9a6/Blog_Header_Hamburger_History_Option.png?fm=jpg&q=80&fl=progressive&w=1100";
for(const image of images) {
// Pick the name of the attribute we want to change based on whether it's <img> or <source>
const srcAttributeName = image.tagName.toLowerCase() == "img" ? "src" : "srcset";
const oldURL = image[srcAttributeName] + "";
if(replaceChecker.test(oldURL)) {
image[srcAttributeName] = replaceWith;
}
}
You could improve that by checking the media attribute and if it says minimum screen width, use URL for smaller image of the hamburger. That is set by the w GET param in the hamburger image's URL.
I am trying to create a notification Icon based application in which I want to display some numbers ranging from 1-999.
I looked at this video which is similar to what I want to do but here the system tray icon just displays the icon and it shows a pop up rather than the system tray icon showing the number or any text.
Excluding the popup item, all I want to do is to read a number (input from somewhere) and display that number in the notification icon section.
I am open to trying any technology (QT, .net) for doing this. Basically, I am looking for some examples.
While parts of your question are vague, this is very possible, I'd even dare-say quite simple. Since you mentioned you're open to trying any technology, C# would probably simplify things for you.
Generate a new 16 x 16 Bitmap and draw the number to it using the Graphics class.
Convert the Image instance to an Icon instance, after disposing of your Graphics object.
Set the Icon property of your NotifyIcon to the icon you've just created.
These are the basic steps. You'll likely need to do some research if you aren't familiar with the classes used.
Thanks for replying to my question. Here is what I came up with. Not sure if this is what you were talking about.
Bitmap bmp = new Bitmap(WindowsFormsApplication2.Properties.Resources._16by16BitmapIcon);
RectangleF rectf = new RectangleF(2, 2, 16, 16);
Graphics g = Graphics.FromImage(bmp);
g.DrawString("99", new Font("Tahoma", 7), Brushes.Blue, rectf);
pictureBox1.Image = bmp;
pictureBox1.Height = bmp.Height;
pictureBox1.Width = bmp.Width;
g.Dispose();
var thumb = (Bitmap)bmp.GetThumbnailImage(64, 64, null, IntPtr.Zero);
thumb.MakeTransparent();
notifyIcon1.Icon = Icon.FromHandle(thumb.GetHicon());
Now my next question could this be done in a better way? This is my first C Sharp app so any suggestions are welcome!
public void ShowText(string text, Font font, Color col)
{
Brush brush = new SolidBrush(col);
// Create a bitmap and draw text on it
Bitmap bitmap = new Bitmap(16, 16);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.DrawString(text, font, brush, 0, 0);
// Convert the bitmap with text to an Icon
Icon icon = Icon.FromHandle(bitmap.GetHicon());
m_notifyIcon.Icon = icon;
}
I have such menu situation:
int menu_create(Ihandle *menu)
{
hamburger = IupItem("&Hamburger", "hamburger");
IupSetAttributes(hamburger, "AUTOTOGGLE=YES, RADIO=YES");
char* ce = "Ćev&apčići";
cevapcici = IupItem(utf8_to_cp1250(ce), "cevapcici");
IupSetAttributes(cevapcici, "AUTOTOGGLE=YES, RADIO=YES");
exit = IupItem("Exit\tAlt+F4", "exit");
img4 = IupLoadImage("icons\\delete_16x16.ico");
IupSetAttributeHandle(exit, "TITLEIMAGE", img4);
menu = IupMenu(
IupSubmenu("File",
IupMenu(
hamburger,
cevapcici,
IupSeparator(),
IupItem("Carro&t", "carrot"),
IupSeparator(),
exit,
NULL)),
NULL);
IupSetFunction("exit", (Icallback)mnu_exit);
... etc...
IupSetHandle("menu", menu);
return IUP_DEFAULT;
}
How to get "radio toggle group" functionality with items hamburger and cevapcici so first turns off a second checkmark and opposite. This is my try but it don't work.
2) I try webbrowser example from IUP suite on my windows 7. Problem is that bad black flickering appear's during resize (increase). Also, background of webbrowser flicker black during showing.
I try a same example on Ubuntu and there flickering appear's too but it is not so much visible since background is there white.
Is here any way to get rid of those flickering or if not to get white background of webbrowser window on windows?
3) Since webbrowser is ole object (on windows) is it possible to use say "print preview" or "zoom" function by reference from IUP handle or at any other way like we used to do from MS programming tools?
wbInstance.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, 150, DBNull.Value)
4) How can I get key_up event fired from IupTree?
5) Interesting situation with IupTabs:
frame3 = IupHbox(mat, val, NULL);
vboxt1 = IupVbox(frame3, NULL);
vboxt2 = IupVbox(frame3, NULL);
IupSetAttribute(vboxt1, "TABTITLE", "First documents... ");
IupSetAttribute(vboxt2, "TABTITLE", "Second documents... ");
tabs = IupTabs(vboxt1, vboxt2, NULL);
hbox1 = IupHbox(tabs, IupVbox(frame, tree, frame2, NULL), NULL);
dlg = IupDialog(hbox1);
When I set frame3 which should be a same for both tabs my GUI frozes.
However, I have to got same "mat" (IupMatrix) in both tabs because by changing tabs other data load in matrix but similar enough to use same matrix and related functions.
What to do here?
1) The RADIO attribute belongs to the IupMenu, not to the IupItem. This also means that all the IupItems inside that menu will be part of the radio.
A workaround would be to manually unset the other toggle inside the action callback.
2) That flicker is not caused by IUP. Don't know why the native controls are doing it.
3) Yes, but you will have to program that using the OLE API. If you take a look at the IupOleControl and IupWebBrower source code and send me the code to do it, I will be happy to add it to IUP.
4) You don't. Use the K_ANY callbacks.
5) You can not reuse a control in different places in any dialog. So you must have two different frames, with two different matrices. What you can do is to encapsulate your matrix, so the same function will create a matrix with the same attributes and callbacks any time you want one.
I am relatively new to the Win32/Windows API (non-MFC), and am trying to change the text colour of a static text control. It is already drawn to the screen in black, but I want to change it to another colour using the Windows Colour Chooser dialog, which is opened on clicking a button. Is this possible?
For the button, the WM_COMMAND message is handled on clicking. So far, I have written:
CHOOSECOLOR ccColour;
ccColour.lStructSize = sizeof(ccColour);
ccColour.hwndOwner = hWnd;
ccColour.rgbResult = crLabelTextColour;
ccColour.Flags = CC_FULLOPEN | CC_RGBINIT;
if (ChooseColor(&ccColour) == TRUE)
{
// crLabelTextColour is a COLORREF global variable assigned on loading the program
crLabelTextColour = ccColour.rgbResult;
}
This code, however, fails with an unhandled exception at the if statement, and I'm not sure why! Other examples seem to write code like this.
ChooseColor() crashes because you are not initializing the CHOOSECOLOR structure completely. You are only setting 3 fields, the rest will contain garbage. You'll need to zero-initialize everything, simple to do:
CHOOSECOLOR ccColour = {0};
I have a storyboard with labels. The label's font is set to System 25.
I wanted to make the font size dynamic, and I set it by code now.
I set breakpoints, so I know that "25" is actually chosen in my code, but the font size still is smaller than when I set it in the storyboard designer.
Does anybody perhaps spot where I might have gone wrong or any caveats that I might have missed?
//set label font size
CGFloat nFontSize;
if (bIsIPad)
{
nFontSize=25.0;
}
else if (bIsIPhone_3GS_4_4s_Or_iPodTouch_3_4)
{
nFontSize=12.0;
}
else if (bIsIphone_5_Or_IPodTouch_5)
{
nFontSize=25.0;
}
UIFont *nFont = [UIFont fontWithName:#"System" size:nFontSize];
captionLabel0.font = nFont;
captionLabel1.font = nFont;
It seems that "fontWithName:#"System"" is not the same as "[UIFont systemFontOfSize:nFontSize];"
The storyboard property page seems to reflect "systemFontOfSize" when it displays the font "System".
When I chose "systemFontOfSize", the results were the same as in the storyboard.
You need to connect your label to outlet (storyboard).
And after that, you set the font size for this label.