Results 1 to 5 of 5

Thread: Reading the value of a QSpinBox

  1. #1
    Join Date
    Jan 2006
    Posts
    15
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Reading the value of a QSpinBox

    Hi,

    sounds simple and probabaly it is... but... Newbie...

    I have a QSpinBox (name property in Qt Designer is s1). According to the documentation

    http://doc.trolltech.com/3.2/qspinbox.html#value

    I want to read its value.

    Now I have a singal/slot which connects a QPushbutton with a LCD display. If I push the button I want to display the value of the spinBox inside the LCD. Inside my ...ui.h FIle I have the follwoing code:

    void Form1::display_result()
    {
    int value1 =5;
    value1= s1.value(); // here is the problem
    result -> display(value1); // result is my LCD element, this line works
    }

    The compiler complains:

    In file included from form1.cpp:28:
    form1.ui.h: In member function `virtual void Form1::display_result()':
    form1.ui.h:18: error: request for member `value' in `this->Form1::s1', which is of non-aggregate type `QSpinBox*'
    make: *** [form1.o] Error 1

    Any idea?

    Regards,
    Jochen

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Reading the value of a QSpinBox

    Show the complete code.
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    Join Date
    Jan 2006
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading the value of a QSpinBox

    Quote Originally Posted by jochen_r
    Hi,



    void Form1::display_result()
    {
    int value1 =5;
    value1= s1.value(); // here is the problem
    result -> display(value1); // result is my LCD element, this line works
    }

    The compiler complains:

    In file included from form1.cpp:28:
    form1.ui.h: In member function `virtual void Form1::display_result()':
    form1.ui.h:18: error: request for member `value' in `this->Form1::s1', which is of non-aggregate type `QSpinBox*'
    make: *** [form1.o] Error 1

    Any idea?

    Regards,
    Jochen
    The problem is that s1 is a pointer to a QSpinBox object. Replace it with the following:

    Qt Code:
    1. value1= s1->value();
    To copy to clipboard, switch view to plain text mode 

    Don't you love descriptive compiler errors?


    Edit: As you can tell, I've gotten this error quite a few times myself.

  4. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Reading the value of a QSpinBox

    Give me the header file.
    Qt 5.3 Opensource & Creator 3.1.2

  5. #5
    Join Date
    Jan 2006
    Posts
    15
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Reading the value of a QSpinBox

    Thanks jakamph, that's it!

    This was the complete code.

    Regards,
    Jochen

Similar Threads

  1. QSpinBox Right-Click
    By mbrusati in forum Qt Programming
    Replies: 4
    Last Post: 30th January 2009, 20:11
  2. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 06:34
  3. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 21:53
  4. QSpinBox with checkbox
    By :db:sStrong in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2007, 14:22
  5. Problem reimplementing QSpinBox in a custom widget
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2006, 09:12

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.