Qt widget to qml



  • First time, I have created a qt widget for my project. Button, signal and slot, thread everything working properly also I have taken output.

    Dialog.h

    #include <QDialog>
    
    namespace Ui {
    class Dialog;
    }
    
    class Dialog : public QDialog
    {
        Q_OBJECT
    
    public:
        explicit Dialog(QWidget *parent = 0);
        ~Dialog();
    
    private:
        Ui::Dialog *ui;
    
    public slots:
    
        void startThread();
        void stopThread();
    
    private slots:
    
        void on_Autonomous_Mode_2_clicked();
        void on_Manual_Mode_2_clicked();
    };
    
    #endif // DIALOG_H
    

    dialog.cpp

    #include "dialog.h"
    #include "ui_dialog.h"
    
    using namespace std;
    
    Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
    {
        ui->setupUi(this);
    
        cout<<" signal and slot"<<endl;
    
        startThreadflag = false;
        stopThreadflag = true;
    }
    
    Dialog::~Dialog()
    {
        delete ui;
    }
    
    void Dialog::on_Autonomous_Mode_2_clicked()
    {
        this->ui->Start_2->setEnabled(true);
        this->ui->Stop_2->setEnabled(true); 
    }
    
    void Dialog::on_Manual_Mode_2_clicked()
    { 
        this->ui->Start_2->setEnabled(false);
        this->ui->Stop_2->setEnabled(false);
    }
    
    void  Dialog:: startThread(){
    
        if(!startThreadflag){
    
        this->ui->Start_2->setEnabled(false);
        this->ui-> Stop_2->setEnabled(true);
    
        }
    }
    
    void Dialog::on_Start_2_clicked()
    {
        startThread();
    }
    
    void Dialog:: stopThread(){
    
        if(!stopThreadflag){
    
            this->ui->Start_2->setEnabled(true);
            this->ui->Stop_2->setEnabled(false);
        }
    }
    
    void Dialog::on_Stop_2_clicked()
    {
        stopThread();
    }
    

    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.

        this->ui->Start_2->setEnabled(true);
        this->ui->Stop_2->setEnabled(false);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.