I have created a qt widget for my project. Button, signal and slot, thread everything working properly also I have taken output.
Dialog.h
public slots:
void startThread();
void stopThread();
};
#endif // DIALOG_H
dialog.cpp
void Dialog:: startThread(){
if(!startThreadflag){
this->ui->Start_2->setEnabled(false);
this->ui-> Stop_2->setEnabled(true);
startThreadflag = true;
stopThreadflag = false;
}
}
void Dialog:: stopThread(){
if(!stopThreadflag){
cout << "Closing threads"<< endl;
this->ui->Start_2->setEnabled(true);
this->ui->Stop_2->setEnabled(false);
stopThreadflag= true;
startThreadflag = false;
}
}
void Dialog::on_Close_clicked()
{
cout<<"close_clicked"<<endl;
this->close();
}
For creating dashboard purpose I have developed same ui in qml, signal and slot everything connected when I press the button signal and slot connected. But I don't know how to connect the label button, set enabled.
that is qt widget code. below that dialog.cpp and qml
dialog.cpp
void Dialog::startThread()
{
cout<<"Start Clicked"<<endl;
emit startbuttonclicked();
}
void Dialog::stopThread()
{
cout<<"Stop Clicked"<<endl;
emit stopbuttonclicked();
}
dashboard.qml : (Like all buttons same)
Item {
Dialog {
id: dialog1;
}
Button {
x:220
y:295
text: "Start"
onClicked: { dialog1.startThread() }
}
}