Results 1 to 3 of 3

Thread: QDoubleSpinBox with commit on every change functionality

  1. #1
    Join Date
    Aug 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDoubleSpinBox with commit on every change functionality

    Good day,

    I am trying to create a subclassed QDoubleSpinBox with the added functionality of commiting data on every valueChanged() signal.

    The reason is that the spinbox is connected to a model via QDataWidgetMapper and the model is also controlling a plot. I want the plot to change instantly, which it does when the spinbox loses focus or enter is pressed, but I want it to change when the spinbox is changed in any way (mousewheel, up/down keys .. ect).

    I have found a dirty way to force the commit - I connect the valueChanged signal to a slot that clears and sets the focus on the spinbox, commiting the data because it loses focus but regaining focus instantly. The side effect is that the buttons on the spinbox no longer visually lower themselves when clicked (they work though).

    I have also checked the source of the QSpinBox and the QAbstractSpinBox to figure out how the data is commited when the enter key is pressed, but am unable to come up with a working solution. I have tried connecting the valueChanged() signal to the editingFinished() signal, i have tried running interpretText() and emiting editingFinished() on every valueChanged - but it does not seem to do what i want.

    Is there an elegant way or even a not-so-elegant way to gain the desired functionality?

    I am using Qt 4.7.2(64 bit) in Ubuntu 11.04 (64 bit).

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    509
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDoubleSpinBox with commit on every change functionality

    Hi, have you tried to connect the valueChanged() signal to the submit() slot of the QDataWidgetMapper?

    Ginsengelf

  3. #3
    Join Date
    Aug 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDoubleSpinBox with commit on every change functionality

    Actually that ended up being the solution The only bothersome thing about it is the fact that all of the mapped widgets commit their data when only one of them is changed. It would be excellent to be able to commit only one mapped widget - e.g. submit(QWidget *).

    It's not a huge bother to program around that, but it requires tweaking the model and the instant-commit functionality is required basically in all the applications I work on (honestly, I kind of expected that to be the default functionaly).

Similar Threads

  1. Change functionality of Symbian Touch Key/Button
    By QtnewbieSE in forum Newbie
    Replies: 0
    Last Post: 28th April 2011, 13:04
  2. Qt Creator Mercurial - Cannot commit,status etc
    By Kerubu in forum Qt Tools
    Replies: 2
    Last Post: 12th August 2010, 14:58
  3. Unable to commit transaction
    By cydside in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 07:47
  4. svn commit error on XP using Qt creator
    By yycking in forum General Discussion
    Replies: 3
    Last Post: 10th April 2009, 08:47
  5. Auto commit in QLineEdit in QTableWidget
    By Corran in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 17:50

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.