Results 1 to 15 of 15

Thread: How to create a mouse offer effect for pushbuttons??

  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default How to create a mouse offer effect for pushbuttons??

    How can i provide mouse over effect to all the pushbuttons in my mainwindow??

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create a mouse offer effect for pushbuttons??

    use stylesheets:

    setStyleSheet(QPushbutton:hover{background-color: red;});

  3. #3
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    i have already used stylesheet background image fro button. I just want to bounce or zoom the button a little on mouse over

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create a mouse offer effect for pushbuttons??

    it was just a demonstration how to use the ":hover"-property. you can define anything you want... larger text, other border color, other text color, other margins etc...

  5. #5
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    Qt Code:
    1. ui->pushButton->setStyleSheet("hover{background-color:red};");
    To copy to clipboard, switch view to plain text mode 
    I have used the code in my constructor. even if it doesnot work??

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

    Default Re: How to create a mouse offer effect for pushbuttons??

    It is :hover, not hover.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    athulms (15th September 2011)

  8. #7
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    it worked for me sir, thanks


    Added after 23 minutes:


    i works when i have not provided any style to the button.

    But i need the mouse over effect on button with a stylesheet already set. I mean i have a button with stylesheet

    Qt Code:
    1. ui->playButton->setStyleSheet("background-repeat:no-repeat; background:none; background-image: url(Yellow/M_playUp.png); border:none;");
    To copy to clipboard, switch view to plain text mode 

    i have to provide a border to the button during mouse over. I used the code
    Qt Code:
    1. ui->playButton->setStyleSheet(":hover{border:black};");
    To copy to clipboard, switch view to plain text mode 

    but the codes doesnot work
    Last edited by athulms; 15th September 2011 at 04:40.

  9. #8
    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: How to create a mouse offer effect for pushbuttons??

    Dear, watch the syntax and have a look at the docs: QWidget::setStyleSheets() overwrites the existing one. So either set all at once or append it. Therefore see QWidget::styleSheet() and QString::append().

  10. #9
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    Qt Code:
    1. ui->pushButton->setStyleSheet("background-image:url(c:/M_aboutUp.png);:hover{background-image:url(c:/M_aboutDown.png)};");
    To copy to clipboard, switch view to plain text mode 

    I have used the above code but no background or mouse over effect appears.

    When i use 2separate stylesheet codes second style works. But overwrites the first code.

  11. #10
    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: How to create a mouse offer effect for pushbuttons??

    Again: SYNTAX! wrap the first statement into a QPushButton block.

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

    Default Re: How to create a mouse offer effect for pushbuttons??

    Or a "*" block.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #12
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    can u pls give the full linecode syntax

    Qt Code:
    1. ui->pushButton->setStyleSheet("QPushButton:{background-image:url(c:/M_aboutUp.png)};:hover{background-image:url(c:/M_aboutDown.png)};");
    To copy to clipboard, switch view to plain text mode 

    I used this an again no change
    Last edited by athulms; 19th September 2011 at 05:04.

  14. #13
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create a mouse offer effect for pushbuttons??

    I'd suggest reading this

  15. #14
    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: How to create a mouse offer effect for pushbuttons??

    AAAhhhh! Come on! Watch the css syntax. Take any css guide and see how the basic syntax is. Even the part of the Qt documentation is enough. Just read it. If you can't manage to look that up, you definitely won't be able to use Qt at all, since there, you also have to use the documentation...

  16. #15
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a mouse offer effect for pushbuttons??

    thanks i got it

Similar Threads

  1. Replies: 2
    Last Post: 22nd April 2011, 13:38
  2. Create PushButtons in Loop
    By homerun4711 in forum Newbie
    Replies: 4
    Last Post: 8th December 2010, 11:39
  3. Replies: 3
    Last Post: 12th May 2010, 13:11
  4. Water waves effect at mouse passage
    By QAlex in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2009, 08:46
  5. Replies: 9
    Last Post: 5th March 2006, 03:31

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.