刚学qt,请教各位大大一个布局问题
不废话,直接上代码
构造函数:
ui->setupUi(this);
resize(300,200);
this->setWindowTitle(tr("欢迎使用,请登录"));
usrname=new QLabel(this);
usrname->setText(tr("用户名"));
password=new QLabel(this);
password->setText(tr("密码"));
usrLineEdit=new QLineEdit(this);
passwordLineEdit=new QLineEdit(this);
QGridLayout *gridLayout=new QGridLayout(this);
gridLayout->addWidget(usrname,0,0,1,1);
gridLayout->addWidget(usrLineEdit,0,1,1,3);
gridLayout->addWidget(password,1,0,1,1);
gridLayout->addWidget(passwordLineEdit,1,1,1,3);
btn_ok=new QPushButton(this);
btn_ok->setText(tr("登录"));
btn_cancel=new QPushButton(this);
btn_cancel->setText(tr("退出"));
QHBoxLayout *hboxLayout=new QHBoxLayout(this);
hboxLayout->setSpacing(60);
hboxLayout->addWidget(btn_ok);
hboxLayout->addWidget(btn_cancel);
QVBoxLayout *vboxLayout=new QVBoxLayout(this);
vboxLayout->setMargin(40);
vboxLayout->addLayout(gridLayout);
vboxLayout->addStretch(40);
vboxLayout->addLayout(hboxLayout);
setLayout(vboxLayout);
定义在这里
QLabel *usrname;
QLabel *password;
QLineEdit *usrLineEdit;
QLineEdit *passwordLineEdit;
QPushButton *btn_ok;
QPushButton *btn_cancel;
使用以上代码生成的ui中button总是在左上角,而且只能显示一个,请问是什么问题。我以前是在linux下操作,现在刚转到woindow下,还想请问下windows和linux下的qt creator使用还有什么区别??