Accept user input using Spinbox



  • Hi,
    I'm developing an application which consists of a Spinbox, Push_button and lineEdit.

    The user has to enter an integer value between 3 and 50 using the Spinbox and press the Push_button. When the Push_button is pressed, QT calls a C code and passes to it as argument the value in Spinbox. Once the C code has run, the result gets displayed in lineEdit.

    Query:
    How should I configure Push_button so as to capture the value in Spinbox? Right clicking Spinbox > 'Go to slot' shows signals such as Valuechanged(int) and (string). Is that the way to go?

    Please help.



  • You need to connect the pushbutton clicked() signal with your slot

    @connect(button,SIGNAL(clicked()),&w,SLOT(myslot()));

    void MyWidget::myslot() {
    int val = spinBox->value().
    }@

    I suggest you read the signal and slots of pushbutton. Look at how to write slots.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.