当前位置:网站首页>Qt: accessing controls in other forms

Qt: accessing controls in other forms

2022-06-10 13:26:00 Xiaoying Information Technology Service Department

Qt Development , There is a large form embedded with a small form , Now you need to get the text of a control in the small form in the code of the large form .

I studied it , Found the answer :

Set the form's ui by public.

Large form :FormCL3P

Little window :Form3PType1

1. The ui Set to public

class Form3PType1 : public QWidget
{
//...
public: // Set to public
    Ui::Form3PType1 *ui;
};

2. Define global small form objects

//G Is a custom global class 
G::form3PType1 = new Form3PType1();

3. Access the controls of the small form in the form

qDebug() << "ANo: " << G::form3PType1->ui->tbxANo->toPlainText();

Interface :

Output :

原网站

版权声明
本文为[Xiaoying Information Technology Service Department]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101246235117.html