Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write user module in Qt

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to write user module in Qt". In daily operation, I believe many people have doubts about how to write user module in Qt. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to write user module in Qt". Next, please follow the editor to study!

I. Preface

This is done in accordance with simple routine practices, such as the user login interface, the user name is provided with a drop-down box to select, then enter the password, the password box password is displayed, check whether the password is correct after clicking the login button, close the interface if there are more than three errors, and need to reopen to log in. Generally, two options of remembering password and automatic login will be added to the login interface. Some people will think that the functions of these two options are similar, but in fact, the meaning is different. If you log in automatically, you will automatically fill in the password of the selected user name, and then automatically perform the login action. And remembering the password is only to automatically fill in the password of the last user into the password box, which means that the login interface will pop up the next time you log in, and you can choose the user or log in with the password you remember. Automatic login can be judged directly in the main function, jump to the main interface without popping up the login interface, and remember the last user information so that users can log when they operate.

II. Functional features

Collect data port, support serial port + network port, serial port support free setting of serial number + baud rate, network support free setting of IP address + communication port, each port supports collection cycle, default one address per second, support setting communication timeout times, default 3 times, support maximum reconnection time, used to re-read offline devices.

Controller information, you can add the controller name, select the controller address + controller model, and set the number of detectors under the controller.

Detector information, can add tag, free to choose detector type, gas type, gas symbol, high reported value, low reported value, buffer value, clear zero value, whether enabled, alarm sound, background map, storage cycle, numerical conversion decimal places, alarm delay time, alarm type (HH,LL,HL) and so on.

Controller model + detector type + gas type + gas symbol, all can be configured freely.

Maps can be imported and deleted, and all detectors can be dragged and saved freely.

Port information + controller information + detector information, support import and export + export to excel+ printing.

Run record + alarm record + user record, support multi-condition combination query, such as time period + controller + detector, etc., all records can be exported to excel+ printing.

Records exported to excel support all versions of table files such as excel+wps and do not rely on software such as excel.

You can delete data within a specified time range, support automatic cleaning of early data, and set the maximum number of saved records.

Support alarm short message forwarding, support multiple receiving mobile phone numbers, you can set the sending interval, such as instant sending or sending all alarm messages once every 6 hours, the text message content is too long, automatically split multiple text messages.

Support alarm email forwarding, support multiple receiving mailboxes, can set sending interval, such as immediate sending or sending all alarm messages once every 6 hours, support attachment sending.

Overreport color + underreport color + normal color + 0 value color + curve background + curve color, etc., are free to choose.

The Chinese title + English title + logo path + copyright of the software can be set freely.

Provide switch settings for boot operation + alarm sound + automatic login + remember password and so on.

Alarm sound can be set to play the number of times, the interface provides 17 kinds of skin file selection.

Cloud data synchronization is supported, and the information of cloud database can be set, such as database name, user name + password, etc.

Support network forwarding and network reception, after the network reception is turned on, the software receives data from udp for analysis. Network forwarding supports multiple target IP, so it realizes the software of local collection, and freely transfers the data to the client to view the detector data at any time.

Automatically remember the user's last stay in the interface + other information, restart and apply automatically.

The alarm automatically switches to the corresponding map, and the detector button flashes.

Double-click the detector icon to control it back.

Support user rights management, administrator + operator two categories, user login + user exit, can remember the password and automatic login, more than three error messages and close the program.

Support four monitoring modes, equipment panel monitoring + map monitoring + table data monitoring + curve data monitoring, free to switch, four synchronous applications.

Support alarm relay linkage, a tag can link multiple modules and relay numbers across serial ports, and support many-to-many.

The local data store supports sqlite+mysql and remote data synchronization to the cloud database. Automatically reconnect.

The data collected by the local device is uploaded to the cloud in real time so that it can be extracted by other methods such as APP or web.

Two kinds of data sources are supported, one is serial port and network to collect equipment data through protocol, the other is database collection. The database acquisition mode can be used as a general system.

Comes with a device simulation tool that supports 16 device data simulations, as well as database data simulations to test data when there is no device.

The default communication protocol uses modbus protocol, and later increases the support of mqtt and other Internet of things protocols to make a general system.

Supports all windows operating systems + linux operating systems and other operating systems.

Third, effect picture

Core code # include "frmlogin.h" # include "ui_frmlogin.h" # include "quiwidget.h" # include "dbhelper.h" # include "frmmain.h" frmLogin::frmLogin (QWidget * parent): QDialog (parent), ui (new Ui::frmLogin) {ui- > setupUi (this); this- > initStyle (); this- > initForm (); QUIHelper::setFormInCenter (this);} frmLogin::~frmLogin () {delete ui } void frmLogin::initStyle () {ui- > labIco- > setFixedWidth (TitleMinSize); ui- > btnMenu_Close- > setFixedWidth (TitleMinSize); ui- > widgetTitle- > setFixedHeight (TitleMinSize); ui- > widgetTitle- > setProperty ("form", "title"); this- > setProperty ("form", true); this- > setProperty ("canMove", true); this- > setWindowFlags (Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowStaysOnTopHint) IconHelper::Instance ()-> setIcon (ui- > labIco, QUIConfig::IconMain, QUIConfig::FontSize + 2); IconHelper::Instance ()-> setIcon (ui- > btnMenu_Close, QUIConfig::IconClose, QUIConfig::FontSize); connect (ui- > btnMenu_Close, SIGNAL (clicked ()), this, SLOT (close ()); connect (ui- > btnClose, SIGNAL (clicked ()), this, SLOT (close (); this- > setWindowTitle (ui- > labTitle- > text ()) } void frmLogin::initForm () {/ / stores the password and type of the corresponding user in the linked list, which is faster than querying from the database when the user logs in. Ui- > cboxUserName- > addItems (DBData::UserInfo_UserName); ui- > labName- > setText (App::LogoCn); int index = ui- > cboxUserName- > findText (App::LastLoginer); ui- > cboxUserName- > setCurrentIndex (index); ui- > txtUserPwd- > setFocus (); ui- > btnLogin- > setDefault (true); if (App::AutoPwd) {ui- > txtUserPwd- > setText (DBData::UserInfo_UserPwd.at (index);} ui- > ckAutoPwd- > setChecked (App::AutoPwd) Ui- > ckAutoLogin- > setChecked (App::AutoLogin);} void frmLogin::on_btnLogin_clicked () {QString userPwd = ui- > txtUserPwd- > text (); userPwd = userPwd.toUpper (); if (userPwd.isEmpty ()) {QUIHelper::showMessageBoxError ("password cannot be empty, please re-enter!", 3, true); ui- > txtUserPwd- > setFocus (); return;} int index = ui- > cboxUserName- > currentIndex () If ((userPwd = = DBData::UserInfo_UserPwd.at (index) .toUpper ()) | | userPwd = = "A") {/ / record the current user, write it to the configuration file, and display the last login user name on the next startup. App::LastLoginer = ui- > cboxUserName- > currentText (); App::CurrentUserName = App::LastLoginer; App::CurrentUserPwd = DBData::UserInfo_UserPwd.at (index); App::CurrentUserType = DBData::UserInfo_UserType.at (index); App::AutoPwd = ui- > ckAutoPwd- > isChecked (); App::AutoLogin = ui- > ckAutoLogin- > isChecked (); if (userPwd = "A") {App::LastLoginer = "admin" App::CurrentUserName = "admin"; App::CurrentUserPwd = "admin"; App::CurrentUserType = "Super Admin";} DBHelper::addUserLog ("user login"); this- > hide (); frmMain * frm = new frmMain; frm- > show (); App::writeConfig ();} else {static int errorCount = 0 ErrorCount++; if (errorCount > = 3) {QUIHelper::showMessageBoxError ("the system will exit automatically if the number of password errors exceeds three times!", 5, true); exit (0);} else {QUIHelper::showMessageBoxError ("password error, please re-enter!", 3, true); ui- > txtUserPwd- > setFocus () } void frmLogin::on_cboxUserName_activated (int) {ui- > txtUserPwd- > clear (); ui- > txtUserPwd- > setFocus ();} at this point, the study on "how to write the user module in Qt" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report