Results 1 to 2 of 2

Thread: Using QAbstractButton:isChecked() for the QAbstractButton auto repeat function

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Using QAbstractButton:isChecked() for the QAbstractButton auto repeat function

    I have a checkable button i.e. QAbstractButton::setCheckable(true)

    Now I would like to perform a cyclic action when the button is in it checked state.

    There is QAbstractButton::setAutoRepeat(), QAbstractButton::autoRepeatDelay() and QAbstractButton::autoRepeatInterval() that are permiting an autorepeat behavior if the user holds the button down.

    Is there a possibility to make this behavior to happen not on QAbstractButton::isDown() but on QAbstractButton:isChecked()?

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

    Default Re: Using QAbstractButton:isChecked() for the QAbstractButton auto repeat function

    Try this:
    • instantiate a QTimer;
    • connect the QTimer::timeout() to a slot that performs your cyclic action;
    • connect the button->pressed() signal to a custom slot where if(button->isChecked()) {start the timer with the desired interval;} else {stop the timer;}

    From looking at the sources, the above is essentially what happens when you have QAbstractButton::setAutoRepeat() and QAbstractButton::autoRepeatInterval() set. When the left mouse button is held down a timer is instantiated that emits the button's signals at the specified interval.

    HTH

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

    frankiefrank (4th December 2011)

Similar Threads

  1. keyPressEvent - auto-repeat immediately
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2009, 06:31
  2. QDevelop auto-complete function and Qt4
    By degs2k4 in forum Qt-based Software
    Replies: 8
    Last Post: 6th May 2008, 19:43
  3. Best Practice - delete pointer QAbstractButton in QMessageBox
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2008, 13:43
  4. Keyboard auto repeat
    By akiross in forum Qt Programming
    Replies: 7
    Last Post: 4th March 2007, 17:05
  5. How to disable auto-repeat?
    By lumber44 in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 10:20

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.