PDA

View Full Version : QIcon Icons are not visible



harakiri
6th May 2007, 18:41
I've got the following problem: a gui i created is started by a c++-thread. now i want to assign own icons to certain menu entries, but the icons aren't shown in the application, but their functionality works fine.
I created another application with a main.cpp that has the following line included:

Q_INIT_RESOURCE(resource_file);

with that line, the icons are shown. both applications have the same ressource file and the same icon folder. so i think i need the q_init_resource in the thread-driven application too.

here's the code of the thread which starts the gui:

void S::run(){
int argc = 0;
char** argv = 0;
m_Application = new QApplication(argc, argv);
m_MainWidget = new MainWindow(this);

if(m_MainWidget){
m_MainWidget->show();
m_Application->exec();

}else{
cout << "GUIThread::run: Could not start Qt-application." << endl;
}
}

neither Q_INIT_RESOURCE(resource_file); nor m_MainWidget->Q_INIT_RESOURCE(resource_file); nor m_Application->Q_INIT_RESOURCE(resource_file); worked, so how can i include the line Q_INIT_RESOURCE(resource_file); to my application so that the icons are displayed correctely? or is there another way(even better?) to add icons to a QAction?

thanks in advance for your help :)

marcel
6th May 2007, 19:11
Could you look at what what Q (http://www.qtcentre.org/forum/qstringlist.html)StringList QResource::searchPaths () return inside the constructor of your MainWindow?

Maybe the paths are not correct. Anyway, Q_INIT_RESOURCE is used when loading resources in static libraries. Here shouldn't be the case...

Do you call Q_INIT_RESOURCE anywhere else in your app? Have you tried calling it right before initializing the QApplication and the MainWindow, in run?

Regards