Results 1 to 2 of 2

Thread: QIcon Icons are not visible

  1. #1
    Join Date
    May 2007
    Posts
    33
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb QIcon Icons are not visible

    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:
    Qt Code:
    1. Q_INIT_RESOURCE(resource_file);
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. void S::run(){
    2. int argc = 0;
    3. char** argv = 0;
    4. m_Application = new QApplication(argc, argv);
    5. m_MainWidget = new MainWindow(this);
    6.  
    7. if(m_MainWidget){
    8. m_MainWidget->show();
    9. m_Application->exec();
    10.  
    11. }else{
    12. cout << "GUIThread::run: Could not start Qt-application." << endl;
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QIcon Icons are not visible

    Could you look at what what QStringList 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

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 08:52
  2. icon visible from explorer
    By ChasW in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2007, 22:30
  3. Suppressing menu icons on the Mac
    By Brandybuck in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 20:00
  4. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 09:37
  5. How do I find out which widgets/canvas items are visible?
    By Tommytrojan in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 14:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.