Results 1 to 3 of 3

Thread: QMainWindow inside a MDIarea as QMDisubwindow. Icon not changing

  1. #1
    Join Date
    Jul 2011
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QMainWindow inside a MDIarea as QMDisubwindow. Icon not changing

    hi,
    I have a QT Gui application that has a MdiArea where I open subwindows, also based on QMainwindow. I've done that essentially because I wanted to have a taskbar on each of the subwindows.
    Everything works fine but the icon in each of the subwindows is the same as the application itself.

    the setWindowTitle works great I can have different windows titles for the subwindows but setWindowIcon has no effect.

    anyone knows how to change the icons in this case?

    An happy new year.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QMainWindow inside a MDIarea as QMDisubwindow. Icon not changing

    Did you make sure the icon (or resourse file) is accessible, watch for warnings in Application Output
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jul 2011
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMainWindow inside a MDIarea as QMDisubwindow. Icon not changing

    Yes I've made sure. And I also used the designer to build the subwindows and in the designer I've put a specific icon that is shown in the preview of the form but then when inserted that window in the mdiarea the icon becames replaced by the icon of the application,
    I even issue the setWindowIcon with a nonexistent icon, as in that case no icon would be used, but always the same result the icon is the icon of the application.

    regards,

    Yes I've made sure. And I also used the designer to build the subwindows and in the designer I've put a specific icon that is shown in the preview of the form but then when inserted that window in the mdiarea the icon becames replaced by the icon of the application,
    I even issue the setWindowIcon with a nonexistent icon, as in that case no icon would be used, but always the same result the icon is the icon of the application.

    regards,

    Yes I've made sure. And I also used the designer to build the subwindows and in the designer I've put a specific icon that is shown in the preview of the form but then when inserted that window in the mdiarea the icon becames replaced by the icon of the application,
    I even issue the setWindowIcon with a nonexistent icon, as in that case no icon would be used, but always the same result the icon is the icon of the application.

    regards,


    Added after 1 45 minutes:


    Qt Code:
    1. this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/Icons/insert-table2.png")));
    2. tablewindow *windowtable=new tablewindow;
    3. //windowtable->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/Icons/insert-table2.png")));
    4. windowtable->setWindowTitle(dialog.fileName);
    5.  
    6. ui->mdiArea->addSubWindow(windowtable,Qt::SubWindow);
    To copy to clipboard, switch view to plain text mode 

    Just to make more clear the above piece of code is in my mainwindow.cpp. when I added the first line of code
    Qt Code:
    1. this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/Icons/insert-table2.png")));
    To copy to clipboard, switch view to plain text mode 
    the Icon of the main application changed as the icon of the subwindow (windowtable)
    just to confirm that really insert-table2.png was acessible.

    The behavior that I was expecting was to change only the subwindow icon through the line
    Qt Code:
    1. //windowtable->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/Icons/insert-table2.png")));
    To copy to clipboard, switch view to plain text mode 
    commented above but was not comented when I tested. I imagine that this is something deep inside qt that makes all the Qmainwindows share the icon of the main Qmainwindows. I may be wrong, obviously.


    regards,
    Last edited by artome; 5th January 2013 at 17:59.

Similar Threads

  1. How to open an external App inside QMainWindow
    By lorik in forum Qt Programming
    Replies: 5
    Last Post: 29th December 2011, 02:07
  2. changing the color of the titlebar of a QMdiSubWindow
    By eric_vi in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2011, 22:41
  3. QMainWindow inside another widget
    By DanFessler in forum Newbie
    Replies: 4
    Last Post: 23rd August 2010, 22:58
  4. Changing icon in sidebar at QFileDialog possible ?
    By skyperhh in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2009, 12:15
  5. QMainWindow: problem changing centralWidget
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 4th October 2007, 14:00

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.