QT4:水平布局管理器QHBoxLayout
2016-09-01 21:58
465 查看
创建一个窗体并排摆放一个按钮一个标签,使他们能够随着窗体的水平缩放而缩放。
实现这个功能需要使用布局管理器中的QHBoxLay进行布局,把这连个组件放入QHBoxlayout中。
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
QHBoxLayout *hlayout=new QHBoxLayout();
QPushButton *button=new QPushButton("im ok");
QLabel *label = new QLabel("Hello Qt!");
QWidget *window = new QWidget;
window->setWindowTitle("main");
hlayout->addWidget(button);
hlayout->addWidget(label);
window->setLayout(hlayout);
window->show();
return app.exec();
}
相关文章推荐
- QT QGridLayout QHBoxLayout QVBoxLayout 布局管理器运用
- Qt 布局之 QHBoxLayout Class
- TableLayout 表格布局管理器
- UI复习-布局管理器RelativeLayout(导航方向菜单)
- [Android步步为营]第4营 布局管理器Layout
- Gtk+的布局(Layout) 一、垂直、水平布局(源代码)
- 【Android开发笔记】 弹出可编辑对话框(布局管理器 LayoutInflater )
- QT5 学习之路15---布局管理器
- QT学习笔记----布局管理器的使用
- Qt之布局管理器
- qt布局(水平、垂直和Grid布局管理器)
- Qt布局之QStackedLayout
- Android开发布局系列: LinearLayout布局实现垂直水平居中
- QT布局之水平垂直加Qss样式布局
- 布局管理器之CardLayout(卡片布局管理器)
- swing学习笔记十一(卡片布局管理器CardLayout )
- Qt入门-layout布局
- Java基础之创建窗口——使用网格布局管理器(TryGridLayout)
- Java.布局管理器.CardLayout-GridLayout
- Qt入门-layout布局