I've changed my mind and now I don't want to compile all resources into application, but load them during runtime instead. According to my experiments I can't use static pointers to QPixmap as class members and create QPixmap objects just once in constructor of my class (load icons directly from disk), because application crashes. When these pointers are not static, application does not crash, but it's not a solution, becuase pixmaps are loaded every time we create another instance of this class.
So I think I will have to use external resource file. I'm not sure if I know how to do it, some questions arise:
1. After I create myresource.rcc file using
rcc -binary myresource.qrc -o myresource.rcc
rcc -binary myresource.qrc -o myresource.rcc
To copy to clipboard, switch view to plain text mode
and load them in main() function before creating any windows:
int main(int argc, char *argv[])
{
QResource::registerResource("/path/to/myresource.rcc");
MainWindow w;
w.show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QResource::registerResource("/path/to/myresource.rcc");
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
all icons will be accessible in the same way as they were compiled in application? This would mean that this code will work:
myLabel.
setPixmap(QPixmap(":/icons/icon.png"));
myLabel.setPixmap(QPixmap(":/icons/icon.png"));
To copy to clipboard, switch view to plain text mode
2. If I'm right about the above, I would like to automate the process of generating myresource.rcc. I guess that when I add myresource.qrc file to my project and build application, all resources are compiled in. I don't want them to be compiled in, but I want them to be accessible from my project in QT Creator. Is this possible?
3. Anyway would you advise using files *.rcc or registering resources directly from files *.png?
===
And some other important questions:
4. If I load 3 pixmaps to 3 different labels in a row, when screen is refreshed (function Paint() or however it is named, is called)? Is it refreshed after each pixmap setting or optimised and refreshed just once?
5. If I have 3 labels in some QLayout and I hide two of them, when will mechanism processing layouts start its work? After each single act of hiding or just once?
Bookmarks