Qt查找子窗口
来源:互联网 发布:ubuntu如何识别u盘 编辑:程序博客网 时间:2024/05/21 21:39
在mfc中最通常的方法是CWnd* GetDlgItem( int nID ) const; 通过能ID获取子窗口;
每个资源都有一个nID作为唯一标识;
在Qt中可以通过 QObject::findChild(const QString & name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const;
T QObject::findChild(const QString & name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.
This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:
QPushButton *button = parentWidget->findChild<QPushButton *>("button1");
This example returns a QListWidget child of parentWidget:
QListWidget *list = parentWidget->findChild<QListWidget *>();
This example returns a child QPushButton of parentWidget (its direct parent) named "button1":
QPushButton *button = parentWidget->findChild<QPushButton *>("button1", Qt::FindDirectChildOnly);
This example returns a QListWidget child of parentWidget, its direct parent:
QListWidget *list = parentWidget->findChild<QListWidget *>(QString(), Qt::FindDirectChildOnly);
//
应用:
对于每个继承与QObject的类,都可以setObjectName(const QString & name)设置类的对象名称。
对于控件类,可以直接在“Qt 设计师”中直接获取,修改。
FROM:http://blog.csdn.net/chinabinlang/article/details/16982235
- Qt查找子窗口
- Qt查找子窗口
- 代码:查找子窗口
- 递归查找子窗口
- QT分割子窗口
- QT。子窗口不析构
- QT开发 查找窗口创建
- Qt子窗口全屏显示
- QT 全屏显示子窗口
- QT MDI子窗口遍历
- Qt子窗口全屏显示
- qt mdi子窗口最大化
- Qt子窗口全屏显示
- Qt 子窗口内嵌到父窗口中
- Qt 代码: 子窗口调用父窗口
- QT 子窗口监听主窗口信号
- Qt实现子窗口内嵌到主窗口内部
- Qt-父窗口和子窗口
- 武术擂台机器人
- iOS 网络解析
- Qt获取控件位置,坐标总结
- Dash 安装 IOS文档 Apple 开发者离线文档下载
- Pycharm创建文件模板
- Qt查找子窗口
- 最全的iOS面试题及答案
- [LeetCode]231. Power of Two
- Qt tip——初始化窗体Geometry()
- MyEclipse使用Maven创建web项目+搭建SSM框架教
- 使用canvas.clipPath来裁剪时部分机型出现问题
- vim配置及插件安装管理
- leetcode-139-Word Break
- NIST: Report on Post-Quantum Cryptography