QT中在MainWindow中代码添加控件
2015-12-04 16:14
981 查看
感谢 http://blog.csdn.net/noodle123/article/details/8260693
代码如下:
Note: Creating a main window without a central widget is not supported. You must
have a central widget even if it is just a placeholder.
QWidget *centerWindow = new QWidget;
代码如下:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1")); QVBoxLayout *vbox = new QVBoxLayout(this); vbox->addWidget(radio1); QWidget *centerWindow = new QWidget(this); this->setCentralWidget(centerWindow); centerWindow->setLayout(vbox); }
Note: Creating a main window without a central widget is not supported. You must
have a central widget even if it is just a placeholder.
QWidget *centerWindow = new QWidget;
this->setCentralWidget(centerWindow);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(splitter);
centerWindow->setLayout(mainLayout);
相关文章推荐
- PyQt之布局&无边框&信号
- Qt界面设计(隐藏窗体标题栏,制作按钮菜单)
- 【Qt】
- 【Qt动画框架】
- 关于WIN64+QT4.8.4+VS2008配置
- Qt Model+View+Delegate
- PyQt5教程(四)——事件与信号
- Qt——右键菜单
- QT链接mysql驱动程序出现的问题详解
- QTableWidget点击item之外空间时信号的获取
- ubuntu下opencv + qt 开发环境的搭建
- 【转】qt中文乱码问题
- QT 控件基础
- QT中QListView中放置自定义控件并添加滚动条
- QT中编译问题
- Qt汉字转拼音
- QT 相关问题
- 第一个PyQt程序
- QT显示框架嵌入Vs控制台工程
- Qwt在Qt中的安装