Results 1 to 4 of 4

Thread: Loading disabled icons

  1. #1
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Loading disabled icons

    I am having trouble while loading disable icon to the application. I want to load two separate icons for instance when the push button is enabled I want to keep same icon that I am loading from UI file (coz it is already embedded in ui file ) but when that push button is disabled I want to load separate icon from some source. I want my icons to switch when the push button is enabled or disabled.

    For instance :-

    Qt Code:
    1. If((False = exitWindow)!!(test_mode =! CurrrenyMode))
    2.  
    3. {
    4.  
    5. if(pWarningButton)
    6.  
    7. {
    8. pWarningButton->setEnabled(false);
    9. //
    10. QString str;
    11. pWarningButton->setIconSet(QPixmap(“…1.png”);
    12. }
    13. }
    14.  
    15.  
    16. else
    17. {
    18. pWarningButton->setEnabled(true);
    19.  
    20.  
    21. }
    22.  
    23.  
    24. //pWarningButton is simple push button that I am loading directly from UI file.
    25. Such as:
    26.  
    27. pWarningButton = (QPushButton*)LoadWindow(mainWindowDlg,strWarning);
    28. if(pWarningButton)
    29. {
    30. pWarningButton ->setEnabled(false);
    31.  
    32. connect(pWarningButton,SIGNAL(clicked()), this, SLOT(Slot1()));
    33. }
    To copy to clipboard, switch view to plain text mode 

    The problem with above code is I got the icon that I have passed as parameter 1.png when button was disabled . But when button is enabled it never switches back to original icon of UI file.

    IS there any way to switch icons according to enable/disable states? Or Do i have to define each time the source of bitmap when button is enabled or disabled.
    Last edited by user_mail07; 12th June 2007 at 02:14. Reason: spelling error

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading disabled icons

    You can add a second pixmap to the icon set so that Qt will swap icons on its own. Just take a look at QIconSet::setPixmap() and use the mode QIconSet:isabled.

  3. #3
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Loading disabled icons

    Thanks a lot that worked.
    Qt Code:
    1. I have another similar question if i need to define different large icon sizes for toolbar and smaller icon size for menubar.
    2.  
    3. if (mToolbar)
    4. {
    5.  
    6. mAction->setIconSet(QPixmap("largeICon" ),QIconset::Large))
    7. }
    8.  
    9. if
    10.  
    11. if (mMenu)
    12. {
    13.  
    14. mAction->setIconSet(QPixmap("smallIcon" ),QIconset::small))
    15. }
    To copy to clipboard, switch view to plain text mode 

    When executes above code it just load only one size icon it overwrites another icon size.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading disabled icons

    Don't change the icon set. Add a pixmap with a different mode to the existing icon set.

Similar Threads

  1. Loading SVG icons
    By user_mail07 in forum Qt Programming
    Replies: 2
    Last Post: 28th June 2007, 04:12

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.