Results 1 to 4 of 4

Thread: Creating flat QPushButton in Linux, without button sinking when clicked

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating flat QPushButton in Linux, without button sinking when clicked

    Thanks for your reply. I haven't tried with QAbstractButton. And I think apart from SetFlat(), I don't need any functionality specific to QPushButton, so I guess QAbstractButton can be tried.
    Btw, after several hits and trials, I have found a solution, although I am not sure how elegant that is.

    So basically, instead of calling "QPushButton:aintEvent(event)" in overridden paintEvent, I am using "drawControl" directly from this function. And here, instead of checking is button is down/checked to set "option.state" to QStyle::State_Sunken/QStyle::State_Raised (as done in QPushButton paintEvent), I am directly setting it to QStyle::State_Raised without any checks. This way the button is never sinks.
    So until I find something more elegant than this, I will consider the issue to be fixed.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating flat QPushButton in Linux, without button sinking when clicked

    That sounds like a suitable solution as well.

    The initial implementation just did too much my calling the base class paintEvent() as a whole, doing what it would have done but leaving out things it should no longer do is a viable approach.

    Cheers,
    _

Similar Threads

  1. QPushbutton, background-color but flat ?
    By gab74 in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2011, 10:15
  2. how i want flat Drop-down Button for ComboBox ?
    By pavanbarot in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2010, 06:50
  3. make a flat QPushButton
    By harmodrew in forum Newbie
    Replies: 2
    Last Post: 6th August 2010, 16:46
  4. How to show QPushButton as flat when it is checked
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 3rd August 2010, 10:07
  5. QPushbutton Flat property and icon appearance.
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2006, 08:30

Tags for this Thread

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.