Results 1 to 4 of 4

Thread: On press of a pushbutton,the pushbutton image should be different

  1. #1
    Join Date
    Nov 2010
    Posts
    30
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default On press of a pushbutton,the pushbutton image should be different

    hello freinds,I have added an background image to a pushbutton ,now when i press this pushbutton,a diffrent image should happen on oushbutton so that the user gets a feel that the button has been pressed..so how shall i do it..




    regards
    ranjit

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: On press of a pushbutton,the pushbutton image should be different

    QPushButton has clicked() signal, connect it to a slot and change the image there.
    signals and slots docs

  3. #3
    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: On press of a pushbutton,the pushbutton image should be different

    You have to subclass QPushButton and do the paint your self. By using QStyledPainter it is not so complicated. Then inside the paint method check for isDown() and react on it.

  4. #4
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: On press of a pushbutton,the pushbutton image should be different

    You can set up different pictures for the several QPushButton states in the Qt designer...

Similar Threads

  1. Enlarge Pushbutton?
    By triperzonak in forum Qt Programming
    Replies: 7
    Last Post: 20th June 2008, 15:58
  2. Zooming on PushButton Press event
    By KosyakOFF in forum Qwt
    Replies: 5
    Last Post: 11th April 2008, 10:12
  3. connecting image to a pushbutton
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 4th December 2007, 10:23
  4. why pushbutton moving??
    By Shuchi Agrawal in forum Qt Tools
    Replies: 7
    Last Post: 19th January 2007, 18:17
  5. pushbutton action
    By mickey in forum Newbie
    Replies: 9
    Last Post: 21st April 2006, 20:46

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.