Results 1 to 7 of 7

Thread: How do I create an Option button like VB?Pressed then down, pressed again then up.

  1. #1
    Join Date
    Jun 2010
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default How do I create an Option button like VB?Pressed then down, pressed again then up.

    At Visual Basic 6 I can create several option buttons, if one pressed, it is in down state, press it again, it pops up.

    Is there a way in QT can do this?

  2. #2
    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: How do I create an Option button like VB?Pressed then down, pressed again then up

    A QToolButton will do what you want I guess.

  3. #3
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I create an Option button like VB?Pressed then down, pressed again then up

    Hi,

    Set the 'checkable' property. Even normal buttons (like a QPushButton) can have this property set.

    Regards,
    Marc

  4. The following user says thank you to marcvanriet for this useful post:

    yyiu002 (4th October 2010)

  5. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: How do I create an Option button like VB?Pressed then down, pressed again then up

    Quote Originally Posted by marcvanriet View Post
    Set the 'checkable' property.
    Quick note to the OP, you can use either
    Qt Code:
    1. setProperty("checkable", QVariant(true));
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. setCheckable(true);
    To copy to clipboard, switch view to plain text mode 
    to do this. I guess some properties are so frequently useful that convenience functions have been added.

  6. #5
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do I create an Option button like VB?Pressed then down, pressed again then up

    the checkable property is definitely right

  7. #6
    Join Date
    Jun 2010
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I create an Option button like VB?Pressed then down, pressed again then up

    One more question, is it possible to have text automatic wrapped to next line if button is narrowed.

  8. #7
    Join Date
    Jun 2010
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I create an Option button like VB?Pressed then down, pressed again then up

    Found how to do it, add "\n" in between text.

Similar Threads

  1. QTableView key pressed
    By radu_d in forum Qt Programming
    Replies: 6
    Last Post: 1st August 2013, 03:20
  2. Raise key pressed event when button is clicked?
    By newstead in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2009, 13:12
  3. Replies: 2
    Last Post: 13th May 2009, 19:01
  4. Getting the row for button pressed
    By steg90 in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2007, 15:45
  5. How to "hide window when close button pressed"
    By iGoo in forum Qt Programming
    Replies: 4
    Last Post: 26th July 2006, 09: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.