Results 1 to 6 of 6

Thread: Spinbox value doesn't decrease after the initial integer value is displayed.

  1. #1
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Spinbox value doesn't decrease after the initial integer value is displayed.

    Spinbox initial integer value is first defined . So for example the initial integer value is 3.
    Qt Code:
    1. int integervalue;
    2. intSpinBox = new QSpinBox;
    3. QString integertostring;
    4. integertostring= QString::number(integervalue);
    5.  
    6. intSpinBox ->setSpecialValueText(integertostring);
    To copy to clipboard, switch view to plain text mode 

    So the first initial integer value is displayed in the spinbox. For example : 3 .
    Then using the spinbox , I click the down button, or, by pressing the down on
    the keyboard, the value in the spinbox doesn't decrease at all as it should.
    The value remains to be 3.(the value is supposed to decrease to 2.)
    However, by clicking the up button, or pressing up on the keyboard can increase the
    value in the spinbox but the increased value is incorrect.From value 3 it changes to 1 instead of 2.

    What is wrong? How do I resolve this bug? SOS !

  2. #2
    Join Date
    Apr 2010
    Posts
    34
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spinbox value doesn't decrease after the initial integer value is displayed.

    I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
    Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

    Additional note:

    As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.
    Last edited by Vit Stepanek; 28th July 2010 at 11:08. Reason: updated contents

  3. #3
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spinbox value doesn't decrease after the initial integer value is displayed.

    Quote Originally Posted by Vit Stepanek View Post
    I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
    Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

    Additional note:

    As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.
    I want to display integer from a variable . The initial integer value cannot be specified as it could be any value that is read from integervalue.So I can't use setValue().
    SOS !

  4. #4
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spinbox value doesn't decrease after the initial integer value is displayed.

    Quote Originally Posted by Vit Stepanek View Post
    I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
    Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

    Additional note:

    As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.
    The value doesn't decrease at all when the spinbox down button is clicked.It must be because the value behind is always '0' . How can I change its behaviour?

  5. #5
    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: Spinbox value doesn't decrease after the initial integer value is displayed.

    Read the documentation. QSpinBox::setValue() is exactly what you want to set the value displayed by the spin box and also the value that is affected by the up/down controls. Get the current value back with value().

    QSpinBox::setSpecialValueText() specifies what the spin box should display when its value equals the minimum() allowable value, e.g. use it if you want the spin box to display "It's zero dude" instead of the integer value when the value == minimum().

  6. #6
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spinbox value doesn't decrease after the initial integer value is displayed.

    SOLVED! Thank you. Use QSpinBox::setValue() and problem solved.



    Quote Originally Posted by ChrisW67 View Post
    Read the documentation. QSpinBox::setValue() is exactly what you want to set the value displayed by the spin box and also the value that is affected by the up/down controls. Get the current value back with value().

    QSpinBox::setSpecialValueText() specifies what the spin box should display when its value equals the minimum() allowable value, e.g. use it if you want the spin box to display "It's zero dude" instead of the integer value when the value == minimum().

Similar Threads

  1. Does bytesAvailable() decrease when read() is called?
    By ShaChris23 in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2010, 21:16
  2. integer as a QTableWidgetItem ?
    By tommy in forum Qt Programming
    Replies: 7
    Last Post: 29th May 2009, 17:44
  3. Decrease the size of Application in Mac?
    By vishal.chauhan in forum Installation and Deployment
    Replies: 2
    Last Post: 26th March 2009, 10:54
  4. How to increase/decrease brightness/sharpness
    By rishiraj in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 06:25
  5. need to decrease the library size
    By rohan_m_e in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th November 2008, 04:38

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.