In Qt Designer 4.7, I am trying to add custom icons to a UI.
When editing the QPushButton or QLabel properties, I'll go to Icon -> Choose File and select my PNG.
I then get this popup error: "The pixmap file 'custom/icon.png' cannot be read."
I have no idea why it won't accept my PNGs. What's weird is there are other PNGs in our database that are accepted by Qt Designer, and I can't tell what properties they have that make them readable. Like, when I select my PNGs in the file browser, the working PNGs have an accurate thumbnail, but the one that doesn't work just has a blank file thumbnail.
What would cause a pixmap PNG to be unreadable by Qt Designer? The icon I'm trying to use is a 4KB 80×80 image made in Paint...
Related
I have couple .png files and I need to create icons for the button.
Initially it will be a first image and when button is clicked and action is successful, the image shall be replaced with the second one.
What I can see, you can create only predetermined Vaadin icons. Documentation does not even provide images of these icons, only names, therefore I can't even decide if any of those icon will be suitable for me.
If anyone knows how to do it, I will appreciate the tip.
The setIcon method of the Button component actually accepts any component as a parameter. Thus if you want to use png-file as a icon, you can just create Image component using png as a resource for it.
Image image = new Image(png);
Button button = new Button("Button");
button.setIcon(image);
The font-icons from Vaadin Icons collection are naturally more light weight, and you can find visual map of the icons here if you use them instead: https://vaadin.com/docs/latest/components/icons
I have a C++ model that is used in QML. It's working fine, but I have problems showing decoration. How can I display icons in QML? I have searched the documentation and the web, no success. Image doesn't work either.
You have two options:
provide the icon as a string with a path to the icon file and use an Image element in QML to load the icon from the path string.
provide the icon as a QImage and use a custom image provider to use the QImage as a source for a QML Image.
The second approach is overkill in your case, but still, image interop between C++ and QML is possible if you need it in future.
I'm working on a Qt UI that will run on a touchscreen. At some point it will be useful to select files, in (probably) a QFileDialog.
But little icons on a QFileDialog leads to a terrible touch-user experience, I'd like them to be bigger, so the user doesn't get crazy trying to navigate in the filesystem.
Actually, I'm searching documentation to see if there is a way through css, but haven't seen yet which target/propery to use.
Given the doc of QFileDialog class:
QFileDialog::Detail 0 Displays an icon, a name, and details for each item in the directory.
QFileDialog::List 1 Displays only an icon and a name for each item in the directory.
You can't set icon size this way. I recommend you to set a custom icon provider on the QFileDialog.
I'm trying to create an Android View with a PNG image displayed as is in it. The only problem is, when I use the "ImageView" option, it will only allow me to create icons (Launcher icon, menu icon...etc.), which are too small to be displayed on my View!
I tried importing the PNG file in the drawable folders manually with "Link to file in the file system" option in the advanced options. That way, it does appear in the Graphical Layout of Eclipse as I want it to, but the XML file refers to a resource android:src="#drawable/myImage.png" that is "not found".
How to solve this?
Thank you in advance.
SOLVED **
Actually, what I did is enter the resource manually in the XML file of my activity as such:
<ImageView
android:src="#drawable/myimage" />
I put the file in all the drawable folders (xhdpi, hdpi, ldpi and mdpi) but in different sizes (200px width for ldpi, 300 for mdpi, 400 for hdpi and 480 for xhdpi). All files' name is myimage.png (but you should not put the extension in the code above!
PS: The reason for which it wasn't working before is that the file name's first letter was capital. I think...
Thanks anyway.
Sorry 'bout editing first post, but the site won't allow me to "answer my own question cuz I'm a newbie". :)
In my last question (Qt/C++: Icons not showing up when program is run) I asked how to get an icon to show up on a toolbar and was told I needed a Qt Resource, which I added and that fixed my problem, the icon did show up on the toolbar.
Now I'm trying to set the title icon of a window, using the same resource file, and it shows up fine in the Qt preview viewer but blank in the actual program. I am using a MainWindow which has an MDIArea and the children are MainWindows as well; neither the parent MDI nor child MDI windows icons will show properly. On the parent, I see the regular "Windows Application icon" and on the child, the icon is completely blank.
How can I solve this?
You will have to go through a standard resource file for windows. (That is, a .rc)
The process (as described in the documentation) is:
Store the ICO file in your application's source code directory, for
example, with the name myappico.ico. Then, create a text file called,
say, myapp.rc in which you put a single line of text:
IDI_ICON1 ICON DISCARDABLE "myappico.ico"
Finally, assuming you are using qmake to generate your makefiles, add this line to your myapp.pro
file: RC_FILE = myapp.rc
Regenerate your makefile and your application. The .exe file will now be represented with your icon in Explorer.
In the Visual Studio case you're simply able to add a resource to your project.