Results 1 to 8 of 8

Thread: Problems with a spinbox Qt creator

  1. #1
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Red face Problems with a spinbox Qt creator

    Hi Im a new user of qt creator and Im creating my first interface, I need to reset the values of 16 doublespinboxes to 0 with a botton, I dont know how to set the values of a spinbox to 0 in qt creator

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problems with a spinbox Qt creator

    Qt Code:
    1. spinbox->setValue(0);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    cmdg (17th July 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problems with a spinbox Qt creator

    Thanks I probe it but the program show me '->' is not a pointer. What should be the problem?

  5. #4
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with a spinbox Qt creator

    there are two way of doing it
    Qt Code:
    1. Spinbox = spin;
    2. spin.setValue(0);
    3.  
    4. //or if you do it with a pointer
    5. // in the Header: Spinbox *spin;
    6.  
    7. spin = new Spinbox;
    8. spin->setValue
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problems with a spinbox Qt creator

    How are you creating QSpinBox? Are you writing code or using Qt Designer?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  7. #6
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problems with a spinbox Qt creator

    Im working on qt designer. The problem is that I put a value manually in each one of the 16 spinboxes and I need to put all in 0 with a button like a reset but the codes I found in the web dont work.

  8. #7
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problems with a spinbox Qt creator

    Set the QSpinBox object name by right click on QSpinBox in Qt Designer and "Change objectName", set to "spinXX", where XX is the number of spin box.

    Then write a slot with code like spinXX->setValue(0); for all the spinboxes, and then connect this slot to the pushbutton clicked signal
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  9. #8
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: Problems with a spinbox Qt creator

    I've already connected that slot to the pushbutton clicked signal but I also need to put spinXX->setValue(0) inside the function and it doesn't work. This is my code

    int MainWindow::new_file()
    {
    angle_1->setValue(0.0);
    }

    It show me again the same mistake: /home/vivi/Documentos/tesis/Codigo Interfaces Vivi/MSR-build-desktop/../MSR/mainwindow.cpp:310: error: base operand of ‘->’ is not a pointer

Similar Threads

  1. OpenMP problems with Qt Creator
    By Coocos in forum Qt Tools
    Replies: 1
    Last Post: 29th November 2010, 14:12
  2. Replies: 7
    Last Post: 31st October 2010, 12:21
  3. Replies: 14
    Last Post: 17th August 2010, 12:17
  4. Complie problems in using Qt Creator.
    By Zmrca in forum Installation and Deployment
    Replies: 4
    Last Post: 20th April 2010, 17:16
  5. Replies: 0
    Last Post: 12th October 2009, 22:37

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.