Results 1 to 6 of 6

Thread: Make a pushbutton flat but on cursor above it to show that it is a button ?

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Make a pushbutton flat but on cursor above it to show that it is a button ?

    When you make button flat, the border goes away, how can I have this border on mouse above button (so as to show better that it is a button) A good example is VLC preferences: it has flat buttons that show you that hey are buttons by showing their border every time your mouse goes above them.

    Thx in advance for any replies
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Make a pushbutton flat but on cursor above it to show that it is a button ?

    Subclass QPushButton and write your own paint event using QStylePainter. To detect if the mouse is currently over the icon, you can reimp enter and leave event or you can simply use QWidget::underMouse().

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

    hakermania (15th January 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Make a pushbutton flat but on cursor above it to show that it is a button ?

    Bonus tip: VLC is opensource and written with Qt

  5. #4
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Make a pushbutton flat but on cursor above it to show that it is a button ?

    I am trying to figure out how to work with the mouseevent
    .h
    Qt Code:
    1. protected:
    2. void mouseMoveEvent(QMouseEvent *);
    To copy to clipboard, switch view to plain text mode 
    .cpp:
    Qt Code:
    1. void MainWindow::mouseMoveEvent(QMouseEvent *){
    2. if (ui->pushButton->underMouse())
    3. cout << "hello\n";
    4. }
    To copy to clipboard, switch view to plain text mode 
    It doesn't work though.. I will check vlc's source as well...
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  6. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Make a pushbutton flat but on cursor above it to show that it is a button ?

    Quote Originally Posted by hakermania View Post
    I am trying to figure out how to work with the mouseevent
    ...
    It doesn't work though.
    The correct way to do this (Object Oriented that is), is to subclass QPushButton and implement the mouse move event function like Lykurg already said.
    Use the mouse event for the mouse details.

  7. #6
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Make a pushbutton flat but on cursor above it to show that it is a button ?

    You can achieve this using Style Sheets and the ":hover" pseudo-state.

Similar Threads

  1. Right-Click menu on a pushButton doesn't show up
    By qtpyqt in forum Qt Programming
    Replies: 6
    Last Post: 9th September 2010, 17:58
  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. Replies: 5
    Last Post: 14th April 2009, 08:27

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.