qt用户登录界面
时间: 2023-07-13 17:22:43 浏览: 48
好的,我可以为您提供一个简单的Qt用户登录界面的示例代码:
```cpp
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *window = new QWidget;
window->setWindowTitle("Login");
QLabel *userLabel = new QLabel("Username:");
QLineEdit *userEdit = new QLineEdit;
QHBoxLayout *userLayout = new QHBoxLayout;
userLayout->addWidget(userLabel);
userLayout->addWidget(userEdit);
QLabel *passLabel = new QLabel("Password:");
QLineEdit *passEdit = new QLineEdit;
passEdit->setEchoMode(QLineEdit::Password);
QHBoxLayout *passLayout = new QHBoxLayout;
passLayout->addWidget(passLabel);
passLayout->addWidget(passEdit);
QPushButton *loginButton = new QPushButton("Login");
QPushButton *cancelButton = new QPushButton("Cancel");
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(loginButton);
buttonLayout->addWidget(cancelButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(userLayout);
mainLayout->addLayout(passLayout);
mainLayout->addLayout(buttonLayout);
window->setLayout(mainLayout);
window->show();
return app.exec();
}
```
这段代码创建了一个简单的窗口,包含一个用户名输入框、一个密码输入框和两个按钮(登录和取消)。您可以将其作为起点,根据您的具体需求进行修改和扩展。