Results 1 to 3 of 3

Thread: Retaining a spinbox value

  1. #1
    Join Date
    Nov 2009
    Posts
    14
    Thanks
    4

    Default Retaining a spinbox value

    Hello, I have a minor problem which confounds me:

    I have a UI which contains a spinbox and a button. The user can choose whatever value can be used in the spinbox's range, but I want it to hold the currently selected value of the spinbox when the button is clicked and transfer it to another function. I have this so far:

    Qt Code:
    1. mainwidget->connect( strt_rcrding_btn, SIGNAL(clicked()), loc_spinbox, SLOT(value() ) ); //hold value of spinbox
    2.  
    3. mainwidget->connect (loc_spinbox,SIGNAL(valueChanged(int) ), &response, SLOT( write_dat_attrib(int) ) ); //and puts it to file
    To copy to clipboard, switch view to plain text mode 

    But QSpinBox::value() is not a valid slot so is there another slot I could use which emits the valueChanged signal? Or is there another way I could code this?

    Thanks
    Last edited by positive_4_life; 19th November 2009 at 17:31.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Retaining a spinbox value

    You have to make your own slot:
    Qt Code:
    1. QObject::connect( strt_rcrding_btn, SIGNAL(clicked()), this, SLOT(yourSlot()));
    2. //...
    3. void XYZ::yourSlot()
    4. {
    5. response->write_dat_attrib(loc_spinbox->value());
    6. }
    To copy to clipboard, switch view to plain text mode 

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

    positive_4_life (19th November 2009)

  4. #3
    Join Date
    Nov 2009
    Posts
    14
    Thanks
    4

    Default Re: Retaining a spinbox value

    Thanks a lot. That solved my problem.

Similar Threads

  1. Replies: 2
    Last Post: 17th November 2009, 17:14
  2. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 12:52
  3. Font size of a spinbox
    By SailinShoes in forum Qt Programming
    Replies: 6
    Last Post: 5th May 2008, 15:29
  4. buttonGroup and spinBox
    By mickey in forum Newbie
    Replies: 9
    Last Post: 21st May 2006, 18:50
  5. a simple question: spinbox
    By mickey in forum Newbie
    Replies: 3
    Last Post: 27th February 2006, 16:37

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
  •  
Qt is a trademark of The Qt Company.