PDA

View Full Version : QPushButton question



[Po]lentino
27th March 2009, 22:30
Hi all,
I'm getting crazy with an annoying behaviour in my app.
This app has a menu with some QPushButton button, with a icon inside.
If I click on my app, it starts but, when the menu pops-up, only the buttons appear, not the icon ...
If i launch my app from console, like

alex@laptop:$ ./myapp
everything works fine, and the buttons are displayed with their icons =\
I know that is stupid, but I can't fix it!
Any suggestion ??

wysota
27th March 2009, 23:49
You are using relative paths to icons in your application. When you start it from the console, the current directory is not changed and the paths are preserved. If you start the program by clicking on it using a file manager, the current directory is most probably set to your home directory and your application is unable to find the files anymore. Either use absolute paths or use QCoreApplication::applicationDirPath() and provide paths relative to your application's binary. Alternatively you can embed the icons directly into the application itself by using Qt's resource system.

[Po]lentino
28th March 2009, 14:28
Thank you wysota, now I'll try with QCoreApplication::applicationDirPath() :)
Resources are an other feature I want to implement in my app, in order to reduce the number of sparse files... but up to now, I've found few examples about managing them with cmake ... and also very aproximative ...
However, again : thank you !!!!