C ++ memo-QT (4), Memo-qt
User Logon-creator Programming
Draw the following interface:
During compilation, the following header file ui_main1_1_h is automatically generated
/*************************************** **************************************** *
** Form generated from reading UI file 'mainwindow. Ui'
**
** Created by: Qt User Interface Compilerversion 5.4.0
**
** WARNING! All changes made in this filewill be lost when recompiling UI file!
**************************************** ****************************************/
# Ifndef UI_MAINWINDOW_H
# Define UI_MAINWINDOW_H
# Include <QtCore/QVariant>
# Include <QtWidgets/QAction>
# Include <QtWidgets/QApplication>
# Include <QtWidgets/QButtonGroup>
# Include <QtWidgets/QHBoxLayout>
# Include <QtWidgets/QHeaderView>
# Include <QtWidgets/QLabel>
# Include <QtWidgets/QLineEdit>
# Include <QtWidgets/QMainWindow>
# Include <QtWidgets/QMenuBar>
# Include <QtWidgets/QPushButton>
# Include <QtWidgets/QStatusBar>
# Include <QtWidgets/QToolBar>
# Include <QtWidgets/QVBoxLayout>
# Include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
Class Ui_MainWindow
{
Public:
QWidget * centralWidget;
QVBoxLayout * verticalLayout;
QHBoxLayout * horizontalLayout_2;
QLabel * userLb;
QLineEdit * userNameLe;
QHBoxLayout * horizontalLayout_3;
...
Write cpp files
Mainwindow. cpp
# Include "mainwindow. h"
# Include "ui_main1_1_h"
# Include <QMessageBox>
MainWindow: MainWindow (QWidget * parent ):
QMainWindow (parent ),
Ui (new Ui: MainWindow)
{
Ui-> setupUi (this );
}
MainWindow ::~ MainWindow ()
{
Delete ui;
}
VoidMainWindow: on_okBt_clicked ()
{
If (ui-> userNameLe-> text (). compare ("user") = 0 & ui-> passWordLe-> text (). compare ("123") = 0)
{
QMessageBox: information (this, "log on to the system", "correct password ",
QMessageBox: OK );
Close ();
}
Else
{
QMessageBox: information (this, "log on to the system", "Incorrect password. Please enter it again! ",
QMessageBox: OK );
}
}
Void MainWindow: on_quitBt_clicked ()
{
If (QMessageBox: information (this, "log on to the system", "exit the system? ",
QMessageBox: Yes, QMessageBox: No) = QMessageBox: Yes ){
Close ();
}
}
All content of this blog is original, if reproduced please indicate the source http://blog.csdn.net/myhaspl/
SetupUi automatically generates some connect relationships, including the following statements:
QMetaObject: connectSlotsByName (MainWindow );
Automatically generate a slot by signal name
For example
Connect (quitBt, SIGNAL (clicked (), this, SLOT (on_quitBt_clicked ));