Results 1 to 2 of 2

Thread: Styling QPushbutton with a Popup QDockWidget

  1. #1
    Join Date
    Jan 2011
    Posts
    70
    Thanks
    43
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Styling QPushbutton with a Popup QDockWidget

    I have set the icon for one of my QPushButtons using the Qt standard icons (as an aside, how do I do this in Designer?)
    Qt Code:
    1. ui->pushButton->setIcon(qApp->style()->standardIcon(QStyle::SP_ArrowRight));
    To copy to clipboard, switch view to plain text mode 

    My desired functionality is to have the button pop up a QDockWidget while clicked/checked, then have it close the QDockWidget when clicked again. The button should be in a depressed state while the dock widget is open and should appear normal when the widget is closed.

    Does this functionality already exist somewhere in another widget, or do I need to recreate it somehow? If I need to recreate it, how do I access the greyed-out version of the standard icon? Basically, I'd like to set the button to appear disabled, but still function as if it's enabled. Is that possible?

  2. #2
    Join Date
    Apr 2012
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Styling QPushbutton with a Popup QDockWidget

    1. to set button pressed you should:
    - setCheckable(true);
    2. to change icon in different states (normal, hover, pressed) you can inherit you class from QPushButton or you can use style sheets (see http://doc.qt.io/qt-4.8/http://doc-snapshot.qt-project.org/4.8/stylesheet.html).
    3. the only one standard push button behavior - show menu (see QPushButton::setMenu).

Similar Threads

  1. SOLVED:QtDesigner:QPushButton PopUp Menu
    By thefatladysingsopera in forum Newbie
    Replies: 0
    Last Post: 21st August 2011, 17:20
  2. QDockWidget styling
    By tipote in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2010, 22:13
  3. Styling QDockWidget's titlebar buttons
    By THRESHE in forum Qt Programming
    Replies: 7
    Last Post: 16th July 2008, 12:30
  4. QPushButton PopUp menu
    By Preeteesh in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2008, 17:03
  5. Problems styling QScrollBar / QPushButton
    By December in forum Qt Programming
    Replies: 0
    Last Post: 20th January 2008, 06:53

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.