QT布局器问题

_cyhcs 2017-10-27 06:46:19
#include "QtGuiApplication20.h"


QtGuiApplication19::QtGuiApplication19(QWidget *parent)
: QWidget(parent)
{
//ui.setupUi(this);
infoLabel = new QLabel(this);
cmdLabel = new QLabel;
cmdLineEdit = new QLineEdit(this);
submitPushButton = new QPushButton(this);
cancelPushButton = new QPushButton(this);
browserPushButton = new QPushButton(this);

QHBoxLayout *cmdLayout = new QHBoxLayout(this);
cmdLayout->addWidget(cmdLabel);
cmdLayout->addWidget(cmdLineEdit);

QHBoxLayout *buttonLayout = new QHBoxLayout(this);
buttonLayout->addWidget(submitPushButton);
buttonLayout->addWidget(cancelPushButton);
buttonLayout->addWidget(browserPushButton);

QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(infoLabel);
mainLayout->addLayout(cmdLayout);
mainLayout->addLayout(buttonLayout);

this->setLayout(mainLayout);
}



1>------ 已启动生成: 项目: QtGuiApplication20, 配置: Debug x64 ------
1> Moc'ing QtGuiApplication20.h...
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(935,5): warning MSB8027: Two or more files with the name of moc_QtGuiApplication20.cpp will produce outputs to the same location. This can lead to an incorrect build result. The files involved are GeneratedFiles\Debug\moc_QtGuiApplication20.cpp, GeneratedFiles\Release\moc_QtGuiApplication20.cpp.
1> moc_QtGuiApplication20.cpp
1> main.cpp
1> QtGuiApplication20.cpp
1> 正在生成代码...
1> qrc_QtGuiApplication20.cpp
1> QtGuiApplication20.vcxproj -> D:\practice\QtGuiApplication20\x64\Debug\QtGuiApplication20.exe
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========

出现此警告,布局也是混乱的,但是如果我只设置一个水平或垂直就一点问题都没有,也能正常显示,这是什么问题呢
...全文
364 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
习惯就好zz 2017-10-28
  • 打赏
  • 举报
回复
无论是水平布局还是垂直布局,系统好像自动会修改的 addWidget(infoLabel, 1);可以试试加个比例系数比如1啊2啊的整数

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧