Results 1 to 6 of 6

Thread: Setting window icon on derived QWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Setting window icon on derived QWidget

    Still the same, the icon is there, but I still just get the default qt one.

    Wondering if it could be something to with that the window is a sub-window? Code I use to add this to my mdi workspace :

    Qt Code:
    1. m_pworkspace->addSubWindow( m_pPlotterView );
    To copy to clipboard, switch view to plain text mode 

    Where m_pPlotterView is my class derived from QWidget.

    The only window I've successfully been able to change icon on is if it is derived from QDialog?

    Regards,
    Steve

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Setting window icon on derived QWidget

    Qt Code:
    1. QMdiSubWindow* subWindow = m_pworkspace->addSubWindow( m_pPlotterView );
    2. subWindow->setWindowIcon(QIcon(QString::fromUtf8(":/QTCanMonitor/Resources/car.png")));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    steg90 (16th July 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Setting window icon on derived QWidget

    • Check out the case. AFAIK Qt resources paths are case-sensitive just like Unix (and unlike Window$ hence the troubles most users of that OS are facing with filenames... ).
    • Is your widget a window (i.e a top level one, either main window, a dialog or a mdi sub window...)
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #4
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Setting window icon on derived QWidget

    Thanks all,

    JPN's solution worked a treat

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
  •  
Qt is a trademark of The Qt Company.