プロジェクト用に qt ウィジェットを作成しました。ボタン、シグナル、スロット、スレッドのすべてが正常に機能し、出力も取得しました。
Dialog.h
public slots:
void startThread();
void stopThread();
};
#endif // DIALOG_H
ダイアログ.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();
}
ダッシュボードの目的を作成するために、qml で同じ ui を開発しました。ボタンを押すと信号とスロットが接続され、すべてが接続されます。しかし、ラベルボタンを接続する方法がわかりません。有効に設定してください。
それはqtウィジェットコードです。その下にdialog.cppとqml
ダイアログ.cpp
void Dialog::startThread()
{
cout<<"Start Clicked"<<endl;
emit startbuttonclicked();
}
void Dialog::stopThread()
{
cout<<"Stop Clicked"<<endl;
emit stopbuttonclicked();
}
dashboard.qml : (すべてのボタンと同じように)
Item {
Dialog {
id: dialog1;
}
Button {
x:220
y:295
text: "Start"
onClicked: { dialog1.startThread() }
}
}