QT - QLineEdit a function of the value of the text obtained is empty

    //文本输入
    rowEdit =new QLineEdit(this);
    rowEdit->setGeometry(500,120,300,40);


    colEdit = new QLineEdit(this);
    colEdit->setGeometry(500,190,300,40);

    MyPushButton *comfirBtn = new MyPushButton(":/images/4.png");
    comfirBtn->setParent(this);
    comfirBtn->move(400,240);

As the above code when we use the text function to get the value entered by the user, its value is empty, the following solution:

1, obtaining the value of the signal at the time slot connection.

connect(comfirBtn,&MyPushButton::clicked,[=](){
        QString row1 = rowEdit->text();
        QString col1 = colEdit->text();
        qDebug()<<row1;
    });

2, the constructor is not acquired.

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_40452317/article/details/92132074