C ++ memo-QT (4), Memo-qt

Source: Internet
Author: User

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 ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.