Results 1 to 3 of 3

Thread: Replacement function for setOn QPushButton qt4?

  1. #1
    Join Date
    Jul 2012
    Posts
    10
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Replacement function for setOn QPushButton qt4?

    Hi -

    I used setOn in my qt3 code for setting a qpushbutton but am having a really hard time finding a way to do it in qt4. My code used to look like:

    pauseButton->setOn(!getActive());

    and I tried

    pauseButton->setCheckable(!getActive());

    However this causes a crash. GDB provides the following output:

    #0 0x00007ffff76a706d in QAbstractButton::setChecked(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

    Any help/advice is appreciated, as I can't seem to figure out what I am doing wrong.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Replacement function for setOn QPushButton qt4?

    The button needs to be set to allow toggling between checked and not checked: QAbstractButton::setCheckable(). Then QAbstractButton::setChecked() can be used to select one of the two states. This sort of button would often be a QToolButton rather than QPushButton.

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

    yapatel (9th April 2014)

  4. #3
    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: Replacement function for setOn QPushButton qt4?

    As Chris said the equivalent to setOn(bool) is setChecked(bool).
    setCheckable(bool) is the equivalent to setToggleButton(bool)

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    yapatel (9th April 2014)

Similar Threads

  1. Replies: 4
    Last Post: 20th October 2011, 12:24
  2. connect a QPushButton matrix with a function
    By harmodrew in forum Newbie
    Replies: 6
    Last Post: 6th August 2010, 12:11
  3. QPushButton function
    By maider in forum Qt Programming
    Replies: 7
    Last Post: 22nd October 2009, 16:01
  4. Console replacement
    By aegis in forum Qt Programming
    Replies: 14
    Last Post: 3rd April 2007, 01:38
  5. Replacement of Images
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 1st March 2007, 11:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.