rmkeller
3rd November 2019, 18:37
Hello Together,
for the last six hours I tried to click a button on a Widget with a function located in the MainWindow class.
I also read a lot in several Formus about this Signal Slot concept.
The best I found is
https://www.qtcentre.org/threads/49866-connect-mainwindow-with-self-made-widgets
But even with this I faild to understand the core problem.
So I if somebody could explain in more detail what to do, could help a lot of people.
I use the QT basic Example "CAN BUS Example"
With QT creator 4.10.1 I droped a new pushButton on the surface of the MainWindow.
Now I simply want to push the "sendbutton" located inside a widget "sendframebox"
Lets say I want to push the button with a timer like this
QTimer::singleShot(2000, []{ qDebug("Button "sendButton" located in sendframebox should be pressed");});
Or a Winwdow function when someting happend...
My code in MainWindow works like this:
void MainWindow::on_radioButton_RUNloop_clicked()
{
if(m_ui->Skript_checkbox_send->isChecked())
{
m_ui->sendFrameBox->sendButton_4(); <- HOW TO PUSH THE BUTTON of the widget??
}
QTimer::singleShot(2000, []{ qDebug("Or push the button with this singleshot timer");});
}
Can somebody tell me how to solve this with the signal slots?
Or how to handle this problem quick and dirty?
Added after 23 minutes:
For the other beginners I solved it quick and dirty with public pushButton function.
But my guess is that it is not really the best solution.
Here the way I solved it "dirty"
In the widget *.h locate a public function:
public:
....
void pushSEND4btn();
...
In the widget *.cpp locate the wrapper code.
void SendFrameBox::pushSEND4btn()
{
m_ui->sendButton_4->click();
}
Now you can press this button from MainWindow:
m_ui->sendFrameBox->pushSEND4btn();
I hope somebody can tell us the right way to solve such a situation.
for the last six hours I tried to click a button on a Widget with a function located in the MainWindow class.
I also read a lot in several Formus about this Signal Slot concept.
The best I found is
https://www.qtcentre.org/threads/49866-connect-mainwindow-with-self-made-widgets
But even with this I faild to understand the core problem.
So I if somebody could explain in more detail what to do, could help a lot of people.
I use the QT basic Example "CAN BUS Example"
With QT creator 4.10.1 I droped a new pushButton on the surface of the MainWindow.
Now I simply want to push the "sendbutton" located inside a widget "sendframebox"
Lets say I want to push the button with a timer like this
QTimer::singleShot(2000, []{ qDebug("Button "sendButton" located in sendframebox should be pressed");});
Or a Winwdow function when someting happend...
My code in MainWindow works like this:
void MainWindow::on_radioButton_RUNloop_clicked()
{
if(m_ui->Skript_checkbox_send->isChecked())
{
m_ui->sendFrameBox->sendButton_4(); <- HOW TO PUSH THE BUTTON of the widget??
}
QTimer::singleShot(2000, []{ qDebug("Or push the button with this singleshot timer");});
}
Can somebody tell me how to solve this with the signal slots?
Or how to handle this problem quick and dirty?
Added after 23 minutes:
For the other beginners I solved it quick and dirty with public pushButton function.
But my guess is that it is not really the best solution.
Here the way I solved it "dirty"
In the widget *.h locate a public function:
public:
....
void pushSEND4btn();
...
In the widget *.cpp locate the wrapper code.
void SendFrameBox::pushSEND4btn()
{
m_ui->sendButton_4->click();
}
Now you can press this button from MainWindow:
m_ui->sendFrameBox->pushSEND4btn();
I hope somebody can tell us the right way to solve such a situation.