Click to confirm output voltage from Arduino
-
Hey guys, I am doing a project to develop a GUI for voltage output from Arduino. The GUI is like this:
Click to confirm output voltage from ArduinoI am wondering if I can make the number I input waits until I click confirm button then sending the signal to Arduino. Because in this stage, once I put the number in the qspinbox, the voltage(number I input) would output from Arduino directly. Is there any way that I can let it waits till I press the Confirm Button for sending signal??
Thank you so much:)
Macive -
Hey guys, I am doing a project to develop a GUI for voltage output from Arduino. The GUI is like this:
Click to confirm output voltage from ArduinoI am wondering if I can make the number I input waits until I click confirm button then sending the signal to Arduino. Because in this stage, once I put the number in the qspinbox, the voltage(number I input) would output from Arduino directly. Is there any way that I can let it waits till I press the Confirm Button for sending signal??
Thank you so much:)
Macive@Macive-Xiong Sure you can. I guess currently you're using http://doc.qt.io/qt-5/qspinbox.html#valueChanged signal to send the value to Arduino, right? If not how are you doing it?
To achieve what you want use http://doc.qt.io/qt-5/qabstractbutton.html#clicked signal of the "Confirm" button. Add a slot and connect it to that signal. I the slot you can get the current value using http://doc.qt.io/qt-5/qspinbox.html#value-prop. -
@Macive-Xiong Sure you can. I guess currently you're using http://doc.qt.io/qt-5/qspinbox.html#valueChanged signal to send the value to Arduino, right? If not how are you doing it?
To achieve what you want use http://doc.qt.io/qt-5/qabstractbutton.html#clicked signal of the "Confirm" button. Add a slot and connect it to that signal. I the slot you can get the current value using http://doc.qt.io/qt-5/qspinbox.html#value-prop.Dear @jsulm,
You always shows up when I face some problem haha. Thank you so much:)
Yes, I use qspinbox for my umber input. I will try the way you suggest and get back to you:) -
Hey guys,
I still have trouble to write the code. I am not sure what codes should I write in the qpushbutton. Here are my code:
Is there any suggestion what codes should I write in the qPushButton ??
Thanks
Macive -
Hey guys,
I still have trouble to write the code. I am not sure what codes should I write in the qpushbutton. Here are my code:
Is there any suggestion what codes should I write in the qPushButton ??
Thanks
Macive@Macive-Xiong Same code as in on_input_box_value_changed? Move the code from on_input_box_value_changed to push button and get the value via http://doc.qt.io/qt-5/qspinbox.html#value-prop
-
@Macive-Xiong Same code as in on_input_box_value_changed? Move the code from on_input_box_value_changed to push button and get the value via http://doc.qt.io/qt-5/qspinbox.html#value-prop
-
@Macive-Xiong This code is completely wrong. Try this way:
void MainWindow::on_push_button_clicked() { MainWindow::updatevolt(QString("%1").arg(ui->doubleSpinBox->value())); }
Make sure MainWindow::on_push_button_clicked() is connected to the clicked signal of the push button.