Unsolved Get bool result of qButton when this is pressed
-
Hello, i need help to obtain the boolean result in a if conditional of a button state.
I have a var called restart, and i need to save a bolean value when i press the button, if is pressed i will save true, if it´s not pressed i will save false.
I need that, because i'm sending in the constructor the value of restart, and i need to capture the moment when is true, becuase later when I release the button the value will be false.
void MainWindow::on_btn_restart_pressed()
{
restart=true;
myOGLW = new MyOpenGLWidget(m_sB,k_sB,b_sB,t_cB,pauser,restart,opc);
}I hope that can you help whit this!!
-
Use signals & slots to send a signal to your
MyOpenGLWidget
which will cause a restart.
https://doc.qt.io/qt-5/signalsandslots.htmlSomething like this (in your MainWindow)
connect(ui->pushbutton_restart, &QPushButton::clicked, myOGLW, &MyOpenGLWidget::restart);
Then, make your widget reset / restart itself (in
myOpenGLWidget
class)