该程序的父类是QDialog,实现一个全屏的登录窗口,现在的布局效果是三行平均布置在该全屏窗口中,我该如何才能将这些控件放置在该全屏窗口的中上部分
#include "login.h"
Login::Login(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
nameLabel = new QLabel(QTextCodec::codecForLocale()->toUnicode("用户名:"));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
nameEdit->actions();
passwdLabel = new QLabel(QTextCodec::codecForLocale()->toUnicode("密 码:"));
passwdEdit = new QLineEdit;
passwdLabel->setBuddy(passwdEdit);
loginButton = new QPushButton(QTextCodec::codecForLocale()->toUnicode("确 定"));
loginButton->setDefault(true);
loginButton->setEnabled(false);
poweroffButton = new QPushButton(QTextCodec::codecForLocale()->toUnicode("关 机"));
poweroffButton->setDefault(true);
poweroffButton->setEnabled(true);
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(nameLabel);
topLayout->addWidget(nameEdit);
QHBoxLayout *middleLayout = new QHBoxLayout;
middleLayout->addWidget(passwdLabel);
middleLayout->addWidget(passwdEdit);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(loginButton);
bottomLayout->addWidget(poweroffButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(topLayout);
mainLayout->addLayout(middleLayout);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
ui.setupUi(this);
}
Login::~Login()
{
}
bool Login::loginServer(const QString *name,const QString *passwd){
return false;
}
void Login::enableLoginButton(const QString &name,const QString &passwd){
}