本文共 4053 字,大约阅读时间需要 13 分钟。
2.从创建过的uimylogin.h中提取以下正确代码
public: Widget(QWidget *parent = nullptr); ~Widget(); //部件 void showFrom(); void showWord(); QGridLayout *gridLayout; QSpacerItem *verticalSpacer_2; QSpacerItem *verticalSpacer; QHBoxLayout *horizontalLayout_4; QSpacerItem *horizontalSpacer; QSpacerItem *horizontalSpacer_4; QVBoxLayout *verticalLayout; QHBoxLayout *horizontalLayout; QLabel *label; QLineEdit *line_user; QHBoxLayout *horizontalLayout_2; QLabel *label_2; QLineEdit *line_passwd; QHBoxLayout *horizontalLayout_3; QPushButton *btn_login; QPushButton *btn_quit; QSpacerItem *horizontalSpacer_3; QSpacerItem *horizontalSpacer_2; };
|
2.widght.cpp文件内容
//呈现窗体部件 void Widget::showFrom(){
if (this->objectName().isEmpty()) this->setObjectName(QString::fromUtf8("this")); this->resize(394, 218); gridLayout = new QGridLayout(this); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); verticalSpacer_2 = new QSpacerItem(20, 37, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(verticalSpacer_2, 4, 0, 1, 1);
verticalSpacer = new QSpacerItem(20, 37, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(verticalSpacer, 0, 0, 1, 1);
horizontalLayout_4 = new QHBoxLayout(); horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4")); horizontalSpacer = new QSpacerItem(38, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_4->addItem(horizontalSpacer);
horizontalSpacer_4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_4->addItem(horizontalSpacer_4);
verticalLayout = new QVBoxLayout(); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); horizontalLayout = new QHBoxLayout(); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); label = new QLabel(this); label->setObjectName(QString::fromUtf8("label")); QFont font; font.setPointSize(14); label->setFont(font);
horizontalLayout->addWidget(label);
line_user = new QLineEdit(this); line_user->setObjectName(QString::fromUtf8("line_user"));
horizontalLayout->addWidget(line_user);
verticalLayout->addLayout(horizontalLayout);
horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); label_2 = new QLabel(this); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setFont(font);
horizontalLayout_2->addWidget(label_2);
line_passwd = new QLineEdit(this); line_passwd->setObjectName(QString::fromUtf8("line_passwd")); line_passwd->setEchoMode(QLineEdit::Password);
horizontalLayout_2->addWidget(line_passwd);
verticalLayout->addLayout(horizontalLayout_2);
horizontalLayout_3 = new QHBoxLayout(); horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); btn_login = new QPushButton(this); btn_login->setObjectName(QString::fromUtf8("btn_login"));
horizontalLayout_3->addWidget(btn_login);
btn_quit = new QPushButton(this); btn_quit->setObjectName(QString::fromUtf8("btn_quit"));
horizontalLayout_3->addWidget(btn_quit);
verticalLayout->addLayout(horizontalLayout_3);
horizontalLayout_4->addLayout(verticalLayout);
horizontalSpacer_3 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_4->addItem(horizontalSpacer_3);
horizontalSpacer_2 = new QSpacerItem(18, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_4->addItem(horizontalSpacer_2);
gridLayout->addLayout(horizontalLayout_4, 1, 0, 1, 1);
QWidget::setTabOrder(line_user, line_passwd); QWidget::setTabOrder(line_passwd, btn_login); QWidget::setTabOrder(btn_login, btn_quit);
}
void Widget::showWord() { this->setWindowTitle(QApplication::translate("mylogin", "mylogin", nullptr)); label->setText(QApplication::translate("mylogin", "\350\264\246\345\217\267:", nullptr)); label_2->setText(QApplication::translate("mylogin", "\345\257\206\347\240\201:", nullptr)); btn_login->setText(QApplication::translate("mylogin", "\347\231\273\345\275\225", nullptr)); btn_quit->setText(QApplication::translate("mylogin", "\345\217\226\346\266\210", nullptr)); }
|
转载地址:http://rcuti.baihongyu.com/