当前位置:网站首页>Qt: 访问其他窗体中的控件
Qt: 访问其他窗体中的控件
2022-06-10 12:46:00 【小鹰信息技术服务部】
Qt开发,有一个大窗体内嵌一个小窗体,现在要在大窗体的代码中获取小窗体中某个控件的文本。
研究了一番,找到了答案:
设置窗体的ui为public.
大窗体:FormCL3P
小窗体:Form3PType1
1. 将小窗体的ui设置为public
class Form3PType1 : public QWidget
{
//...
public: //设置为public
Ui::Form3PType1 *ui;
};2. 定义全局的小窗体对象
//G是自定义全局类
G::form3PType1 = new Form3PType1();3. 在窗体中访问小窗体的控件
qDebug() << "ANo: " << G::form3PType1->ui->tbxANo->toPlainText();界面:

输出:

边栏推荐
- Idea custom configuration link Nacos
- Development trend of Web Development
- 2022 ciscn preliminary satool
- 用GNN做CV三大任务的新骨干,同计算成本性能不输CNN、ViT与MLP|中科院&华为诺亚开源...
- Some coding tips
- [golang] when creating a structure with configuration parameters, how should the optional parameters be transferred?
- Error:top-left corner pixel must be either opaque white or transparent.
- 施一公等团队登Science封面:AI与冷冻电镜揭示「原子级」NPC结构,生命科学突破
- Some words from ShareIt group
- The deep neural network classifies nearly 2billion images per second, and the new brain like optical classifier chip is on nature
猜你喜欢

2022 ciscn preliminary satool

How can the team be dissolved...

Stereo vision based semantic 3D object and ego motion tracking for automotive driving

eKuiper Newsletter 2022-05|protobuf 编解码支持、可视化拖拽编写规则

How about the one-stop machine learning opening platform mlflow?

Start with interpreting the code automatically generated by BDC, and explain the program components of sapgui

Today, a couple won the largest e-commerce IPO in Hong Kong

Start with interpreting the code automatically generated by BDC, and explain the trial version of the program components of sapgui

【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结

NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
随机推荐
JS global timer case
Start with interpreting the code automatically generated by BDC, and explain the program components of sapgui
Wei Lai: "pinches" the data and "pinches" the future
Neuron newsletter 2022-05 | add 2 southbound drivers and 1 northbound application, and realize customized extension with Modbus TCP
Performance test plan (plan) template
CF894C Marco and GCD Sequence
深度神经网络每秒分类近20亿张图像,新型类脑光学分类器芯片登上Nature
No spitting
Student status management system
[mobile robot] principle of wheel odometer
Today, a couple won the largest e-commerce IPO in Hong Kong
[flinlk] dynamic Kerberos authentication in Flink pit
On distributed transaction
3. 网页开发工具 VS Code
Office technical lecture: punctuation - English - Encyclopedia
如何才能把团队给带解散。。。
Automatic mapping of tailored landmark representations for automated driving and map learning
20-year technical veteran gives up his CTO title! Why did the startup attract him?
'setbackgrounddrawable() 'is deprecated, setbackgrounddrawable is obsolete
Colmap source code reading notes [1] threading cc