博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2021年信创系统实战Qt5.9-第四节手动创建登录功能实现
阅读量:4144 次
发布时间:2019-05-25

本文共 4053 字,大约阅读时间需要 13 分钟。

  1. 手动创建项目

 

     2.从创建过的uimylogin.h中提取以下正确代码

  1. widgth.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(394218);

           gridLayout = new QGridLayout(this);

           gridLayout->setObjectName(QString::fromUtf8("gridLayout"));

           verticalSpacer_2 = new QSpacerItem(2037QSizePolicy::MinimumQSizePolicy::Expanding);

 

           gridLayout->addItem(verticalSpacer_24011);

 

           verticalSpacer = new QSpacerItem(2037QSizePolicy::MinimumQSizePolicy::Expanding);

 

           gridLayout->addItem(verticalSpacer0011);

 

           horizontalLayout_4 = new QHBoxLayout();

           horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));

           horizontalSpacer = new QSpacerItem(3820QSizePolicy::ExpandingQSizePolicy::Minimum);

 

           horizontalLayout_4->addItem(horizontalSpacer);

 

           horizontalSpacer_4 = new QSpacerItem(4020QSizePolicy::ExpandingQSizePolicy::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(4020QSizePolicy::ExpandingQSizePolicy::Minimum);

 

           horizontalLayout_4->addItem(horizontalSpacer_3);

 

           horizontalSpacer_2 = new QSpacerItem(1820QSizePolicy::ExpandingQSizePolicy::Minimum);

 

           horizontalLayout_4->addItem(horizontalSpacer_2);

 

 

           gridLayout->addLayout(horizontalLayout_41011);

 

           QWidget::setTabOrder(line_userline_passwd);

           QWidget::setTabOrder(line_passwdbtn_login);

           QWidget::setTabOrder(btn_loginbtn_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));

 

C、展现效果

转载地址:http://rcuti.baihongyu.com/

你可能感兴趣的文章
Objective-C 基础入门(一)
查看>>
Flutter Boost的router管理
查看>>
C++模板
查看>>
【C#】如何实现一个迭代器
查看>>
【C#】利用Conditional属性完成编译忽略
查看>>
VUe+webpack构建单页router应用(一)
查看>>
(python版)《剑指Offer》JZ01:二维数组中的查找
查看>>
Spring MVC中使用Thymeleaf模板引擎
查看>>
深入了解php底层机制
查看>>
PHP中的stdClass 【转】
查看>>
XHProf-php轻量级的性能分析工具
查看>>
OpenCV gpu模块样例注释:video_reader.cpp
查看>>
就在昨天,全球 42 亿 IPv4 地址宣告耗尽!
查看>>
Mysql复制表以及复制数据库
查看>>
Linux分区方案
查看>>
如何使用 systemd 中的定时器
查看>>
git命令速查表
查看>>
linux进程监控和自动重启的简单实现
查看>>
OpenFeign学习(三):OpenFeign配置生成代理对象
查看>>
OpenFeign学习(四):OpenFeign的方法同步请求执行
查看>>