【QT用户登录与界面跳转】

Qt中登录界面跳转到主界面的两种方法 Qt中登录界面跳转到主界面的两种方法1 登录界面跳转2 跳转的两种方式2.1 利用QDialog::Accepted2.2 利用QObject::connect( ) 1 登录界面跳转 登录界面跳转,应该是项目的常见需求了。 输入账号、密码后,点击登录按钮跳转。 2 跳转的两种方式 这里博主介绍两种登录界面跳转到主界面的两种可行方式。 2.1 利用QDialog::Accepted 自然,这个方法创建的登录界面类需要继承QDialog类。 设计好登录界面后,选择 go to slot,再选 阅读详情
AI摘要

本文介绍了使用Qt框架创建简单用户登录界面,并根据用户输入验证后跳转到【QT串口助手】主界面的过程。包括项目设置、登录界面与串口主界面设计、登录逻辑实现、串口界面功能定义及测试等内容,还提醒了实际开发需考虑的细节。

1.前言

在Qt应用程序开发中,实现用户登录及界面跳转功能是构建交互式应用的重要步骤之一。下面将介绍如何使用Qt框架来创建一个简单的用户登录界面,并根据用户的输入信息进行验证,然后跳转到相应的【QT串口助手】主界面。
源码地址:https://gitee.com/vor2345/qt5_login_serial

2. 项目设置

首先,确保你的开发环境中已安装了Qt及其相关工具(如Qt Creator),前期也安装过QT(参考博客:【Qt安装与简易串口控制Arduino开发板小灯教程】)。本文记录一下用QT Creator 写一个用户登录与界面串口助手的过程,整个工程只有几百行代码,跟着做下来对新手来说可以更快了解整个QT项目的开发过程和一些常用控件的使用方法。最好每个功能自己都试试增加自信心!
💕💕💕
先来看看作品:
在这里插入图片描述

3.设计登录界面

3.1 login.pro参数

  1. 设置login.pro参数,导入core gui serialport库
 QT       += core gui serialport

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp \
    serial.cpp

HEADERS += \
    mainwindow.h \
    serial.h

FORMS += \
    mainwindow.ui \
    serial.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
    source.qrc

3.2 界面设置

界面设置分为登录界面和串口主界面

3.2.1 登录界面

在这里插入图片描述
这个登录界面是为智能船舶自主航行系统设计的,提供了简洁而功能齐全的用户登录体验。界面顶部展示有系统名称,明确了这是进入系统的入口。用户需要输入账号和密码来验证身份,其中密码输入框支持显示或隐藏密码的功能以增强使用便捷性。此外,提供了一个“记住账号密码”的选项,方便用户的下次登录。整个背景采用了半透明处理的船舶图像,既美化了界面也强化了品牌形象,使得登录过程更加直观友好。底部还设有一个“忘记密码”链接,为用户提供了找回密码的途径。整体设计注重用户体验,确保了安全性和易用性的平衡。
mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>501</width>
    <height>403</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QFrame" name="frame">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>20</y>
      <width>431</width>
      <height>351</height>
     </rect>
    </property>
    <property name="frameShape">
     <enum>QFrame::StyledPanel</enum>
    </property>
    <property name="frameShadow">
     <enum>QFrame::Raised</enum>
    </property>
    <widget class="QGroupBox" name="groupBox">
     <property name="geometry">
      <rect>
       <x>20</x>
       <y>20</y>
       <width>391</width>
       <height>311</height>
      </rect>
     </property>
     <property name="font">
      <font>
       <pointsize>14</pointsize>
      </font>
     </property>
     <property name="title">
      <string>智能船舶自主航行系统软件登录</string>
     </property>
     <widget class="QPushButton" name="pushButton">
      <property name="geometry">
       <rect>
        <x>100</x>
        <y>260</y>
        <width>161</width>
        <height>41</height>
       </rect>
      </property>
      <property name="font">
       <font>
        <pointsize>20</pointsize>
       </font>
      </property>
      <property name="text">
       <string>登录</string>
      </property>
     </widget>
     <widget class="QCheckBox" name="checkBox">
      <property name="geometry">
       <rect>
        <x>80</x>
        <y>230</y>
        <width>121</width>
        <height>21</height>
       </rect>
      </property>
      <property name="font">
       <font>
        <pointsize>11</pointsize>
       </font>
      </property>
      <property name="text">
       <string>记住账号密码</string>
      </property>
     </widget>
     <widget class="QCommandLinkButton" name="commandLinkButton">
      <property name="geometry">
       <rect>
        <x>220</x>
        <y>220</y>
        <width>101</width>
        <height>41</height>
       </rect>
      </property>
      <property name="font">
       <font>
        <family>Segoe UI</family>
        <pointsize>11</pointsize>
       </font>
      </property>
      <property name="text">
       <string>忘记密码</string>
      </property>
     </widget>
     <widget class="QLineEdit" name="accout">
      <property name="geometry">
       <rect>
        <x>100</x>
        <y>90</y>
        <width>201</width>
        <height>31</height>
       </rect>
      </property>
     </widget>
     <widget class="QLineEdit" name="password">
      <property name="geometry">
       <rect>
        <x>100</x>
        <y>150</y>
        <width>201</width>
        <height>31</height>
       </rect>
      </property>
     </widget>
     <widget class="QLabel" name="label">
      <property name="geometry">
       <rect>
        <x>40</x>
        <y>90</y>
        <width>71</width>
        <height>31</height>
       </rect>
      </property>
      <property name="font">
       <font>
        <family>华文中宋</family>
        <pointsize>14</pointsize>
       </font>
      </property>
      <property name="text">
       <string>账号:</string>
      </property>
     </widget>
     <widget class="QLabel" name="label_2">
      <property name="geometry">
       <rect>
        <x>40</x>
        <y>150</y>
        <width>71</width>
        <height>31</height>
       </rect>
      </property>
      <property name="font">
       <font>
        <family>华文中宋</family>
        <pointsize>14</pointsize>
       </font>
      </property>
      <property name="text">
       <string>密码:</string>
      </property>
     </widget>
     <widget class="QRadioButton" name="radioButton">
      <property name="geometry">
       <rect>
        <x>310</x>
        <y>155</y>
        <width>81</width>
        <height>21</height>
       </rect>
      </property>
      <property name="text">
       <string>显示</string>
      </property>
     </widget>
    </widget>
   </widget>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>

3.2.2 串口主界面

在这里插入图片描述
该串口工具界面设计用于简化与串行设备的通信过程,设计过程参考【QT串口助手】,提供直观的操作体验。界面主要分为几个关键部分:

  • 串口配置区域:用户可以在此选择和配置串口参数,包括端口号、波特率、数据位、校验位以及停止位,以确保与目标设备正确匹配。
  • 操作控制按钮:包含检测串口、打开/关闭串口等按钮,便于用户快速操作串口连接状态。
  • 接收设置选项:允许用户根据需求调整接收数据的方式,如启用Hex显示模式、添加时间戳以及自动换行功能,方便查看接收到的数据。
  • 发送设置选项:提供Hex发送模式及发送后自动换行的功能,同时支持设定自动发送间隔时间,适合需要周期性发送数据的应用场景。
  • 数据交互区:分为发送数据区和接收数据显示区,前者让用户输入要发送到串口的数据,后者实时展示从串口接收到的信息,两者均配备了清空内容的快捷按钮,提升用户体验。

整体而言,此串口界面旨在为用户提供一个高效且易于使用的平台,以便于进行串口通信调试和管理,满足不同应用场景下的串口操作需求。
serial.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Serial</class>
 <widget class="QMainWindow" name="Serial">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>578</width>
    <height>527</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QGroupBox" name="groupBox_4">
    <property name="geometry">
     <rect>
      <x>200</x>
      <y>10</y>
      <width>351</width>
      <height>481</height>
     </rect>
    </property>
    <property name="title">
     <string>数据交互</string>
    </property>
    <widget class="QWidget" name="formLayoutWidget">
     <property name="geometry">
      <rect>
       <x>0</x>
       <y>20</y>
       <width>341</width>
       <height>451</height>
      </rect>
     </property>
     <layout class="QFormLayout" name="formLayout">
      <item row="0" column="0">
       <widget class="QLabel" name="label_2">
        <property name="text">
         <string>发送数据</string>
        </property>
       </widget>
      </item>
      <item row="1" column="0" colspan="2">
       <widget class="QTextEdit" name="textEdit_send"/>
      </item>
      <item row="2" column="0">
       <widget class="QLabel" name="label">
        <property name="text">
         <string>接收数据</string>
        </property>
       </widget>
      </item>
      <item row="3" column="0" colspan="2">
       <widget class="QTextEdit" name="textEdit_recv">
        <property name="readOnly">
         <bool>true</bool>
        </property>
       </widget>
      </item>
      <item row="4" column="0" colspan="2">
       <layout class="QHBoxLayout" name="horizontalLayout_2">
        <item>
         <spacer name="horizontalSpacer">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>40</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
         <widget class="QPushButton" name="send_Bt">
          <property name="text">
           <string>发送数据</string>
          </property>
         </widget>
        </item>
        <item>
         <spacer name="horizontalSpacer_2">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>40</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
         <widget class="QPushButton" name="clear_send_Bt">
          <property name="text">
           <string>清空发送区</string>
          </property>
         </widget>
        </item>
        <item>
         <spacer name="horizontalSpacer_4">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>40</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
       </layout>
      </item>
     </layout>
    </widget>
   </widget>
   <widget class="QGroupBox" name="groupBox">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>10</y>
      <width>191</width>
      <height>311</height>
     </rect>
    </property>
    <property name="title">
     <string>串口配置</string>
    </property>
    <widget class="QWidget" name="gridLayoutWidget_2">
     <property name="geometry">
      <rect>
       <x>10</x>
       <y>20</y>
       <width>169</width>
       <height>281</height>
      </rect>
     </property>
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="1" column="0">
       <spacer name="verticalSpacer">
        <property name="orientation">
         <enum>Qt::Vertical</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
          <width>20</width>
          <height>40</height>
         </size>
        </property>
       </spacer>
      </item>
      <item row="2" column="0">
       <widget class="QPushButton" name="Serial_check_Bt">
        <property name="minimumSize">
         <size>
          <width>93</width>
          <height>28</height>
         </size>
        </property>
        <property name="text">
         <string>检测串口</string>
        </property>
       </widget>
      </item>
      <item row="3" column="0">
       <widget class="QPushButton" name="open_serial_Bt">
        <property name="minimumSize">
         <size>
          <width>93</width>
          <height>28</height>
         </size>
        </property>
        <property name="text">
         <string>打开串口</string>
        </property>
       </widget>
      </item>
      <item row="0" column="0">
       <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0" columnstretch="0,0">
        <property name="sizeConstraint">
         <enum>QLayout::SetDefaultConstraint</enum>
        </property>
        <property name="leftMargin">
         <number>0</number>
        </property>
        <property name="topMargin">
         <number>0</number>
        </property>
        <property name="rightMargin">
         <number>0</number>
        </property>
        <property name="bottomMargin">
         <number>0</number>
        </property>
        <property name="horizontalSpacing">
         <number>6</number>
        </property>
        <property name="verticalSpacing">
         <number>0</number>
        </property>
        <item row="3" column="0">
         <widget class="QLabel" name="label_databit">
          <property name="minimumSize">
           <size>
            <width>72</width>
            <height>30</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>30</height>
           </size>
          </property>
          <property name="text">
           <string>数据位:</string>
          </property>
         </widget>
        </item>
        <item row="4" column="0">
         <widget class="QLabel" name="label_parity">
          <property name="minimumSize">
           <size>
            <width>72</width>
            <height>30</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>30</height>
           </size>
          </property>
          <property name="text">
           <string>校验位:</string>
          </property>
         </widget>
        </item>
        <item row="1" column="1">
         <widget class="QComboBox" name="serial_Cb">
          <property name="minimumSize">
           <size>
            <width>87</width>
            <height>22</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>15</height>
           </size>
          </property>
         </widget>
        </item>
        <item row="5" column="0">
         <widget class="QLabel" name="label_stopbit">
          <property name="minimumSize">
           <size>
            <width>72</width>
            <height>30</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>30</height>
           </size>
          </property>
          <property name="text">
           <string>停止位:</string>
          </property>
         </widget>
        </item>
        <item row="5" column="1">
         <widget class="QComboBox" name="stopbit_Cb">
          <property name="minimumSize">
           <size>
            <width>87</width>
            <height>22</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>15</height>
           </size>
          </property>
          <item>
           <property name="text">
            <string>none</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>奇校验</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>偶校验</string>
           </property>
          </item>
         </widget>
        </item>
        <item row="4" column="1">
         <widget class="QComboBox" name="checkbit_Cb">
          <property name="minimumSize">
           <size>
            <width>87</width>
            <height>22</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>15</height>
           </size>
          </property>
          <item>
           <property name="text">
            <string>1</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>1.5</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>2</string>
           </property>
          </item>
         </widget>
        </item>
        <item row="2" column="1">
         <widget class="QComboBox" name="baundrate_Cb">
          <property name="minimumSize">
           <size>
            <width>87</width>
            <height>22</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>15</height>
           </size>
          </property>
          <property name="currentText">
           <string>9600</string>
          </property>
          <property name="currentIndex">
           <number>3</number>
          </property>
          <item>
           <property name="text">
            <string>1200</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>2400</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>4800</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>9600</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>19200</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>38400</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>57600</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>115200</string>
           </property>
          </item>
         </widget>
        </item>
        <item row="1" column="0">
         <widget class="QLabel" name="label_serialport">
          <property name="minimumSize">
           <size>
            <width>72</width>
            <height>30</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>30</height>
           </size>
          </property>
          <property name="text">
           <string>端口号:</string>
          </property>
         </widget>
        </item>
        <item row="2" column="0">
         <widget class="QLabel" name="label_baudrate">
          <property name="minimumSize">
           <size>
            <width>72</width>
            <height>30</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>30</height>
           </size>
          </property>
          <property name="text">
           <string>波特率:</string>
          </property>
         </widget>
        </item>
        <item row="3" column="1">
         <widget class="QComboBox" name="databit_Cb">
          <property name="minimumSize">
           <size>
            <width>87</width>
            <height>22</height>
           </size>
          </property>
          <property name="maximumSize">
           <size>
            <width>76</width>
            <height>15</height>
           </size>
          </property>
          <property name="currentText">
           <string>8</string>
          </property>
          <item>
           <property name="text">
            <string>8</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>7</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>6</string>
           </property>
          </item>
          <item>
           <property name="text">
            <string>5</string>
           </property>
          </item>
         </widget>
        </item>
       </layout>
      </item>
     </layout>
    </widget>
   </widget>
   <widget class="QGroupBox" name="groupBox_2">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>330</y>
      <width>191</width>
      <height>81</height>
     </rect>
    </property>
    <property name="title">
     <string>接收设置</string>
    </property>
    <widget class="QWidget" name="formLayoutWidget_2">
     <property name="geometry">
      <rect>
       <x>10</x>
       <y>20</y>
       <width>189</width>
       <height>56</height>
      </rect>
     </property>
     <layout class="QFormLayout" name="formLayout_2">
      <item row="0" column="0">
       <widget class="QPushButton" name="clear_recv_Bt">
        <property name="text">
         <string>清空接收</string>
        </property>
       </widget>
      </item>
      <item row="0" column="1">
       <widget class="QCheckBox" name="recv_hex_Chb">
        <property name="text">
         <string>Hex接收</string>
        </property>
       </widget>
      </item>
      <item row="1" column="0">
       <widget class="QCheckBox" name="recv_time_Chb">
        <property name="text">
         <string>时间戳</string>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
       <widget class="QCheckBox" name="recv_autoline_Chb">
        <property name="text">
         <string>自动换行</string>
        </property>
       </widget>
      </item>
     </layout>
    </widget>
   </widget>
   <widget class="QGroupBox" name="groupBox_3">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>420</y>
      <width>191</width>
      <height>71</height>
     </rect>
    </property>
    <property name="title">
     <string>发送设置</string>
    </property>
    <widget class="QWidget" name="layoutWidget">
     <property name="geometry">
      <rect>
       <x>10</x>
       <y>20</y>
       <width>183</width>
       <height>49</height>
      </rect>
     </property>
     <layout class="QGridLayout" name="gridLayout_5">
      <item row="0" column="0">
       <widget class="QCheckBox" name="send_hex_Chb">
        <property name="text">
         <string>Hex发送</string>
        </property>
       </widget>
      </item>
      <item row="0" column="1" colspan="2">
       <widget class="QCheckBox" name="send_line_Chb">
        <property name="text">
         <string>发送新行</string>
        </property>
       </widget>
      </item>
      <item row="1" column="0">
       <widget class="QCheckBox" name="autosend_Chb">
        <property name="text">
         <string>自动发送</string>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
       <widget class="QSpinBox" name="txtSendMs">
        <property name="minimumSize">
         <size>
          <width>60</width>
          <height>0</height>
         </size>
        </property>
        <property name="readOnly">
         <bool>false</bool>
        </property>
       </widget>
      </item>
      <item row="1" column="2">
       <widget class="QLabel" name="label_3">
        <property name="text">
         <string>ms</string>
        </property>
       </widget>
      </item>
     </layout>
    </widget>
   </widget>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>578</width>
     <height>23</height>
    </rect>
   </property>
   <widget class="QMenu" name="menu">
    <property name="title">
     <string>串口工具</string>
    </property>
   </widget>
   <widget class="QMenu" name="menuTCP">
    <property name="title">
     <string>TCP工具</string>
    </property>
   </widget>
   <widget class="QMenu" name="menuUDP">
    <property name="title">
     <string>UDP工具</string>
    </property>
   </widget>
   <widget class="QMenu" name="menuCAN">
    <property name="title">
     <string>CAN工具</string>
    </property>
   </widget>
   <widget class="QMenu" name="menu_2">
    <property name="title">
     <string>画图工具</string>
    </property>
   </widget>
   <addaction name="menu"/>
   <addaction name="menuTCP"/>
   <addaction name="menuUDP"/>
   <addaction name="menuCAN"/>
   <addaction name="menu_2"/>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>

4. 实现登录逻辑

main.cpp主程序进入界面

#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

在对应的mainwindow.cpp文件中实现登录逻辑:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "serial.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , settings(new QSettings("YourCompany", "YourApp"))
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // 设置背景图片
    QFile file(":/ship.png"); // 如果使用资源系统,请根据实际情况调整路径
    if(file.exists()) {
        this->setStyleSheet("MainWindow { background-image: url(:/ship.png)};");
    } else
    {
        qDebug() << "Background image not found!";
    }
    //隐匿密码
    ui->password->setEchoMode(QLineEdit::Password);
    //登录按钮
    connect(ui->pushButton, &QPushButton::clicked, this, &MainWindow::login);
    //按钮传参显示密码按钮
    connect(ui->radioButton, &QPushButton::clicked, this, &MainWindow::display_psd);
    // 记住密码复选框
    connect(ui->checkBox, &QCheckBox::stateChanged, this, &MainWindow::saveSettings);
    loadSettings();
}

MainWindow::~MainWindow()
{
    delete ui;
    delete settings;
}


void MainWindow::login()
{
    saveSettings();
    QString nameString = ui->accout->text();
    QString pswdString = ui->password->text();

    // 检查用户名和密码是否匹配
    if ((nameString == QString::fromLocal8Bit("admin") && pswdString == QString::fromLocal8Bit("123456")) ||
            (nameString == QString::fromLocal8Bit("user") && pswdString == QString::fromLocal8Bit("111111"))) {
        Serial* w = new Serial(); // 使用 'this' 作为父对象,Qt 会自动管理其生命周期
        qDebug() << "Creating Software instance.";
        this->close();
        w->show();
    } else
    {
        QMessageBox::about(this, "警告", "用户名或密码错误");
    }
}

void MainWindow::display_psd(bool checked)
{
    if (checked) {
        //显示密码
        ui->password->setEchoMode(QLineEdit::Normal);
    }
    else {
        //密文显示
        ui->password->setEchoMode(QLineEdit::Password);
    }
}

void MainWindow::saveSettings()
{
    bool remember = ui->checkBox->isChecked();
    QString username = ui->accout->text();
    QString password = ui->password->text();

    settings->setValue("remember", remember);
    if (remember) {
        settings->setValue("username", username);
        settings->setValue("password", password);
    } else {
        settings->remove("username");
        settings->remove("password");
    }
}
void MainWindow::loadSettings()
{
    bool remember = settings->value("remember", false).toBool();
    QString username = settings->value("username", "").toString();
    QString password = settings->value("password", "").toString();

    ui->checkBox->setChecked(remember);
    ui->accout->setText(username);
    ui->password->setText(password);
}

这段代码实现了一个简单的登录窗口,具备记住密码、显示/隐藏密码和基本的用户验证功能。以下是各部分的功能概述:

  1. 构造函数 MainWindow::MainWindow:

    • 初始化主窗口,设置背景图片(如果存在),并初始化一些UI元素。
    • 为密码输入框设置密码模式(即隐藏输入字符)。
    • 连接按钮和复选框到相应的槽函数,以便处理用户的交互操作。
    • 调用 loadSettings() 函数加载上次保存的设置。
  2. 析构函数 MainWindow::~MainWindow:

    • 清理资源,包括删除UI对象和设置对象。
  3. login 函数:

    • 验证用户名和密码是否正确。如果匹配,则关闭当前登录窗口,并打开一个新的 Serial 窗口。
    • 如果不匹配,弹出一个警告消息框提示用户名或密码错误。
  4. display_psd 函数:

    • 根据复选框的状态切换密码输入框的显示模式:如果选中则显示密码文本,否则隐藏(以圆点形式显示)。
  5. saveSettings 和 loadSettings 函数:

    • saveSettings:根据复选框状态决定是否保存用户名和密码。如果用户选择了“记住密码”,则将这些信息保存到应用设置中;否则,从设置中移除这些信息。
    • loadSettings:在启动时读取保存的设置,并根据这些设置更新UI组件(例如,自动填写用户名和密码,以及勾选“记住密码”复选框)。

整体来说,这段代码主要实现了以下功能:

  • 提供了一个图形界面用于用户登录。
  • 支持记住用户凭据的功能,方便用户下次登录。
  • 提供了显示/隐藏密码选项,增加了用户体验。
  • 在验证用户身份后,可以跳转到另一个应用界面(Serial 窗口)。

请注意,直接存储密码的做法存在安全风险,在实际应用中应采用更安全的方式处理用户认证信息。
mainwindow.h预定义槽函数,导入QT相关的库

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QSettings>
#include <QFile>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    QSettings *settings;

private slots:
    void login();
    void saveSettings();
    void loadSettings();

    void display_psd(bool checked);

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

5.串口界面

serial.h预定义串口相关功能函数,导入串口的库文件

#ifndef SERIAL_H
#define SERIAL_H

#include <QMainWindow>
#include <QSerialPort>
#include <QString>
#include <QSerialPortInfo>
#include <QMessageBox>
#include <QTimer>
#include <QTime>
#include <QPainter>
#include <QDebug>
namespace Ui {
class Serial;
}

class Serial : public QMainWindow
{
    Q_OBJECT

public:
    explicit Serial(QWidget *parent = nullptr);
    ~Serial();
    QSerialPort *serialPort;//定义串口指针


private slots:
    //    void on_button_openserial_clicked();

    /*手动连接槽函数*/
    void manual_serialPortReadyRead();

    void on_chkTimSend_stateChanged(int arg1);
    /*以下为mainwindow.ui文件中点击“转到槽”自动生成的函数*/
    void on_Serial_check_Bt_clicked();

    void on_open_serial_Bt_clicked();

    void on_send_Bt_clicked();

    void on_clear_recv_Bt_clicked();

    void on_clear_send_Bt_clicked();
private:
    Ui::Serial *ui;
    // 发送、接收字节计数
    long sendNum, recvNum;
    QLabel *lblSendNum;
    QLabel *lblRecvNum;
    QLabel *lblPortState;
    void setNumOnLabel(QLabel *lbl, QString strS, long num);

    // 定时发送-定时器
    QTimer *timSend;

};

#endif // SERIAL_H

serial.cpp实现定义串口相关功能函数

#include "serial.h"
#include "ui_serial.h"
#include "QSerialPortInfo"
#include <QSerialPort>
#include <QMessageBox>
#include <QDateTime>
#include <QStatusBar>
Serial::Serial(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Serial)
{
    ui->setupUi(this);
    QStringList serialNamePort;
    serialPort = new QSerialPort(this);
    connect(serialPort,SIGNAL(readyRead()),this,SLOT(manual_serialPortReadyRead()));/*手动连接槽函数*/

    /*找出当前连接的串口并显示到serailCb*/
    on_Serial_check_Bt_clicked();

    // 发送、接收计数清零
    sendNum = 0;
    recvNum = 0;
    // 状态栏
    QStatusBar *sBar = statusBar();
    // 状态栏的收、发计数标签
    lblSendNum = new QLabel(this);
    lblRecvNum = new QLabel(this);
    lblPortState = new QLabel(this);
    lblPortState->setText("Connected");
    //设置串口状态标签为绿色 表示已连接状态
    lblPortState->setStyleSheet("color:red");

    // 设置标签最小大小
    lblSendNum->setMinimumSize(100, 20);
    lblRecvNum->setMinimumSize(100, 20);
    lblPortState->setMinimumSize(550, 20);
    setNumOnLabel(lblSendNum, "S: ", sendNum);
    setNumOnLabel(lblRecvNum, "R: ", recvNum);
    // 从右往左依次添加
    sBar->addPermanentWidget(lblPortState);
    sBar->addPermanentWidget(lblSendNum);
    sBar->addPermanentWidget(lblRecvNum);

    // 定时发送-定时器
    timSend = new QTimer;
    timSend->setInterval(1000);// 设置默认定时时长1000ms
    connect(timSend, &QTimer::timeout, this, [=](){on_send_Bt_clicked();});

}

Serial::~Serial()
{
    if(ui != nullptr){
        delete ui;
        delete serialPort;
        delete timSend;
        delete lblSendNum;
        delete lblRecvNum;
        delete lblPortState;
    }

}




void Serial::on_Serial_check_Bt_clicked()
{
    ui->serial_Cb->clear();
    //通过QSerialPortInfo查找可用串口
    foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
    {
        ui->serial_Cb->addItem(info.portName());
    }

}


void Serial::on_open_serial_Bt_clicked()
{
    /*串口初始化*/
    QSerialPort::BaudRate baudRate;
    QSerialPort::DataBits dataBits;
    QSerialPort::StopBits stopBits;
    QSerialPort::Parity checkBits;
    baudRate=QSerialPort::Baud9600;
    dataBits=QSerialPort::Data8;
    stopBits=QSerialPort::OneStop;
    checkBits = QSerialPort::NoParity;
    // 获取串口波特率
    // baudRate = ui->baundrate_Cb->currentText().toInt();直接字符串转换为 int 的方法

    if(ui->baundrate_Cb->currentText()=="1200")
        baudRate=QSerialPort::Baud1200;
    else if(ui->baundrate_Cb->currentText()=="2400")
        baudRate=QSerialPort::Baud2400;
    else if(ui->baundrate_Cb->currentText()=="4800")
        baudRate=QSerialPort::Baud4800;
    else if(ui->baundrate_Cb->currentText()=="9600")
        baudRate=QSerialPort::Baud9600;
    else if(ui->baundrate_Cb->currentText()=="19200")
        baudRate=QSerialPort::Baud19200;
    else if(ui->baundrate_Cb->currentText()=="38400")
        baudRate=QSerialPort::Baud38400;
    else if(ui->baundrate_Cb->currentText()=="57600")
        baudRate=QSerialPort::Baud57600;
    else if(ui->baundrate_Cb->currentText()=="115200")
        baudRate=QSerialPort::Baud115200;

    // 获取串口数据位
    if(ui->databit_Cb->currentText()=="5")
        dataBits=QSerialPort::Data5;
    else if(ui->databit_Cb->currentText()=="6")
        dataBits=QSerialPort::Data6;
    else if(ui->databit_Cb->currentText()=="7")
        dataBits=QSerialPort::Data7;
    else if(ui->databit_Cb->currentText()=="8")
        dataBits=QSerialPort::Data8;

    // 获取串口停止位
    if(ui->stopbit_Cb->currentText()=="1")
        stopBits=QSerialPort::OneStop;
    else if(ui->stopbit_Cb->currentText()=="1.5")
        stopBits=QSerialPort::OneAndHalfStop;
    else if(ui->stopbit_Cb->currentText()=="2")
        stopBits=QSerialPort::TwoStop;

    // 获取串口奇偶校验位
    if(ui->checkbit_Cb->currentText() == "none"){
        checkBits = QSerialPort::NoParity;
    }else if(ui->checkbit_Cb->currentText() == "奇校验"){
        checkBits = QSerialPort::OddParity;
    }else if(ui->checkbit_Cb->currentText() == "偶校验"){
        checkBits = QSerialPort::EvenParity;
    }

    // 初始化串口属性,设置 端口号、波特率、数据位、停止位、奇偶校验位数
    serialPort->setPortName(ui->serial_Cb->currentText());
    serialPort->setBaudRate(baudRate);
    serialPort->setDataBits(dataBits);
    serialPort->setStopBits(stopBits);
    serialPort->setParity(checkBits);

    // 根据初始化好的串口属性,打开串口
    // 如果打开成功,反转打开按钮显示和功能。打开失败,无变化,并且弹出错误对话框。
    if(ui->open_serial_Bt->text() == "打开串口"){
        if(serialPort->open(QIODevice::ReadWrite) == true){
            //QMessageBox::
            ui->open_serial_Bt->setText("关闭串口");
            // 让端口号下拉框不可选,避免误操作(选择功能不可用,控件背景为灰色)
            ui->serial_Cb->setEnabled(false);
        }else{
            QMessageBox::critical(this, "错误提示", "串口打开失败!!!\r\n该串口可能被占用\r\n请选择正确的串口");
        }
        //statusBar 状态栏显示端口状态
        QString sm = "%1 OPENED, %2, 8, NONE, 1";
        QString status = sm.arg(serialPort->portName()).arg(serialPort->baudRate());
        lblPortState->setText(status);
        lblPortState->setStyleSheet("color:green");
    }else{
        serialPort->close();
        ui->open_serial_Bt->setText("打开串口");
        // 端口号下拉框恢复可选,避免误操作
        ui->serial_Cb->setEnabled(true);
        //statusBar 状态栏显示端口状态
        QString sm = "%1 CLOSED";
        QString status = sm.arg(serialPort->portName());
        lblPortState->setText(status);
        lblPortState->setStyleSheet("color:red");
    }

}


void Serial::on_send_Bt_clicked()
{
    QByteArray array;

    //Hex复选框
    if(ui->send_hex_Chb->checkState() == Qt::Checked){
        //array = QString2Hex(data);  //HEX 16进制
        array = QByteArray::fromHex(ui->textEdit_send->toPlainText().toUtf8()).data();
    }else{
        //array = data.toLatin1();    //ASCII
        array = ui->textEdit_send->toPlainText().toLocal8Bit().data();
    }

    if(ui->send_line_Chb->checkState() == Qt::Checked){
        array.append("\r\n");
    }
    // 如发送成功,会返回发送的字节长度。失败,返回-1。
    int a = serialPort->write(array);
    // 发送字节计数并显示
    if(a > 0)
    {
        // 发送字节计数
        sendNum += a;
        // 状态栏显示计数值
        setNumOnLabel(lblSendNum, "S: ", sendNum);
    }
}


void Serial::on_clear_recv_Bt_clicked()
{
    ui->textEdit_recv->clear();
    // 清除接收字节计数
    sendNum = 0;
    // 状态栏显示计数值
    setNumOnLabel(lblSendNum, "S: ", sendNum);
}


void Serial::on_clear_send_Bt_clicked()
{
    ui->textEdit_send->clear();
    // 清除发送字节计数
    sendNum = 0;
    // 状态栏显示计数值
    setNumOnLabel(lblSendNum, "S: ", sendNum);
}

// 定时发送开关 选择复选框
void Serial::on_chkTimSend_stateChanged(int arg1)
{
    // 获取复选框状态,未选为0,选中为2
    if(arg1 == 0){
        timSend->stop();
        // 时间输入框恢复可选
        ui->txtSendMs->setEnabled(true);
    }else{
        // 对输入的值做限幅,小于10ms会弹出对话框提示
        if(ui->txtSendMs->text().toInt() >= 10){
            timSend->start(ui->txtSendMs->text().toInt());// 设置定时时长,重新计数
            // 让时间输入框不可选,避免误操作(输入功能不可用,控件背景为灰色)
            ui->txtSendMs->setEnabled(false);
        }else{
            ui->autosend_Chb->setCheckState(Qt::Unchecked);
            QMessageBox::critical(this, "错误提示", "定时发送的最小间隔为 10ms\r\n请确保输入的值 >=10");
        }
    }
}



/*手动实现接收数据函数*/
void Serial::manual_serialPortReadyRead()
{
    QByteArray recBuf = serialPort->readAll();

    QString str_rev;

    // 接收字节计数
    recvNum += recBuf.size();
    // 状态栏显示计数值
    setNumOnLabel(lblRecvNum, "R: ", recvNum);

    if(ui->recv_hex_Chb->checkState() == false){
        if(ui->recv_time_Chb->checkState() == Qt::Checked){
            QDateTime nowtime = QDateTime::currentDateTime();
            str_rev = "[" + nowtime.toString("yyyy-MM-dd hh:mm:ss") + "] ";
            str_rev += QString(recBuf).append("\r\n");
        }
        else{
            // 在当前位置插入文本,不会发生换行。如果没有移动光标到文件结尾,会导致文件超出当前界面显示范围,界面也不会向下滚动。
            //ui->recvEdit->appendPlainText(buf);

            if(ui->recv_autoline_Chb->checkState() == Qt::Checked){
                str_rev = QString(recBuf).append("\r\n");
            }
            else
            {
                str_rev = QString(recBuf);
            }
        }
    }else{

        // 16进制显示,并转换为大写
        QString str1 = recBuf.toHex().toUpper();//.data();
        // 添加空格
        QString str2;
        for(int i = 0; i<str1.length (); i+=2)
        {
            str2 += str1.midRef (i,2);
            str2 += " ";
        }
        if(ui->recv_time_Chb->checkState() == Qt::Checked)
        {
            QDateTime nowtime = QDateTime::currentDateTime();
            str_rev = "[" + nowtime.toString("yyyy-MM-dd hh:mm:ss") + "] ";
            str_rev += str2.append("\r\n");
        }
        else
        {
            if(ui->recv_autoline_Chb->checkState() == Qt::Checked)
                str_rev += str2.append("\r\n");
            else
                str_rev = str2;

        }
    }
    ui->textEdit_recv->insertPlainText(str_rev);
    ui->textEdit_recv->moveCursor(QTextCursor::End);

}


// 状态栏标签显示计数值
void Serial::setNumOnLabel(QLabel *lbl, QString strS, long num)
{
    // 标签显示
    QString strN;
    strN.sprintf("%ld", num);
    QString str = strS + strN;
    lbl->setText(str);
}


6.测试功能

在这里插入图片描述
运行此代码,弹出登录界面
在这里插入图片描述

输入用户密码
admin123456
user111111

这里有两个账号,点击记住密码,下次就可以不输入密码直接登录就接入串口界面
在这里插入图片描述

在这里插入图片描述
然后配置串口参数打开串口,这就可以正常收发啦!

7.总结

以上就是使用Qt实现基本的用户登录以及界面跳转的过程。实际开发过程中,你可能还需要考虑更多细节,比如数据加密存储、网络通信安全等。此外,对于多窗口的应用程序,良好的架构设计有助于管理不同窗口之间的交互和状态维护。
🛹🛹🛹从而实现对外部世界进行感知,充分认识这个有机与无机的环境🥳🥳🥳科学地合理地进行创作和发挥效益,然后为人类社会发展贡献一点微薄之力。🤣🤣🤣

如果你有任何问题,可以通过下面的二维码加入鹏鹏小分队,期待与你思维的碰撞😘😘😘

参考文献:
相关好文推荐:

  1. QT初体验:手把手带你写一个自己的串口助手
  2. 【Qt安装与简易串口控制Arduino开发板小灯教程】
  3. 【QT串口助手】
QT实现页面间的跳转 页面间跳转(信号与槽) 一、创建界面 要实现页面间的跳转首先你得创建两个或两个以上的界面。 可以通过右键文件夹选择Add new,再选择QT、QT设计师界面,然后选择界面类型,来创建一个新的页面。 二、添加控件 在你想要实现跳转的第一个引发跳转的页面上加入一个控件。 右键,选择转到槽,会跳转页面并自动生成一个槽函数,此时不要管这个槽函数。 找到第一个引发跳转页面的.h文件; 进入之后在此文件下定义一个信号(此页面发射跳转信号); signals: void showmain() 阅读详情

相关推荐

QT实现简单验证的页面跳转

LINUX爱好者! 该文章的项目是基于LINUX下的QT。 转载请标明出处! QT实现简单的页面跳转 以登录功能为例,本项目将默认类作为主界面(main_widgt),创建的新类(login_widget)作登录界面。 #ifndef LOGIN_WIDGET_H #define LOGIN_WIDGET_H #include #include #inc

qq_32953869的博客 2173

QT登录界面设计及跳转主界面

QT软件开发登录界面,并进行主界面跳转

MelyLenient的博客 7200

Qt登录与计算器界面跳转实战

Qt框架是一个跨平台的C++应用程序开发框架,它提供了创建图形用户界面应用程序所需的工具和库。它由挪威公司Trolltech开发,并在2008年被诺基亚公司收购。现在它是Digia公司的产品。Qt不仅用于创建桌面应用程序,还可以用于开发移动应用、嵌入式系统等。Qt Designer 是 Qt 框架提供的一种图形界面设计工具,它允许开发者以所见即所得(WYSIWYG)的方式快速构建 GUI 应用程序的用户界面。在安装 Qt 时,通常会同时安装 Qt Designer。

weixin_42430341的博客 1096

Qt 登录窗口跳转主窗口

登录模块实现 把用户密码信息存储在xml文件里,通过读取xml文件实现登录功能。 注: 需要在 .pro文件 添加 xml,QT += core gui xml loginfo.xml文件信息如下: 登录窗口,如下图: 代码 mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow :

weixin_42906066的博客 6870

使用QT与Access数据库打造登录系统及页面跳转

Qt框架是Nokia开发的一套用于创建跨平台应用程序的工具集,支持从桌面应用到移动应用、嵌入式设备等多种平台。它包含了一套功能齐全的库,能够满足从UI设计到网络编程、数据库连接和多线程处理的多样化需求。Microsoft Access是一种广泛使用的数据库管理系统(DBMS),它提供了数据存储、查询、管理和报告功能。Access数据库文件通常以.mdb或.accdb扩展名存在,前者是早期版本的文件格式,而后者是较新的版本格式。

weixin_32098457的博客 1142

QT 实现登陆页面跳转到主页面源码

实现登陆页面跳转到主页面源码

QT C++实战:实现用户登录页面及多个界面跳转

主要思路 - 一个登录界面,以管理员Or普通用户登录 - 管理员:一个管理员的操作界面,可以把数据录入到数据库中。有返回登陆按钮,可以选择重新登陆(管理员Or普通用户 - 普通用户:一个主界面,负责展示视频和检测。有返回登陆按钮,可以选择重新登陆(管理员Or普通用户

Yaoyao2024的博客 9719

QT登陆页面跳转到主界面的源代码

QT登陆页面跳转到主界面的实现 相关博客详细介绍链接https://blog.csdn.net/apple8422?orderby=ViewCount

【Qt学习】 多用户登录跳转界面

【Qt学习】 多用户登录跳转界面

m0_56051805的博客 1750

C#利用S7netplus实现西门子S7_200_SMART PLC高效点位监控与操作

本文详细介绍了如何使用C#结合S7netplus开源库高效监控与操作西门子S7-200 SMART PLC的点位。内容涵盖从开发环境搭建、建立通信连接,到核心的点位读写、批量数据处理及字节与位数组转换等关键技术,并提供了构建稳定监控程序的架构与避坑指南,帮助开发者快速实现上位机与PLC的稳定数据交互。

rum55的博客 319

微磁模拟实战指南:从OOMMF安装到首个3D模型运行

本文详细介绍了OOMMF微磁模拟软件的安装与使用,从环境配置到首个3D模型运行的完整教程。涵盖Windows、Linux和macOS平台的安装避坑指南,以及MIF文件编写、并行计算优化等实战技巧,帮助研究人员快速掌握这一开源工具在磁畴壁运动、磁滞回线等微磁学问题中的应用。

weixin_29294597的博客 161

Qt登录界面实现以及跳转不同界面

Qt制作登录界面并按权限进行跳转到不同界面(简易版) 实现的逻辑代码也非常简单,主要就是用到了QDialog(注意在此基础上才可以使用accept()函数和Accepted配合使用)。通过全局变量传递权限的选择。enter是登录界面,Info是登录后需要跳转的界面。下面是完整代码: enter.cpp enter.h Info.cpp Info.h mian.h 以上就是完整代码,如果对你有帮助,记得点个赞再走呦~...

weixin_46701594的博客 6175

第一篇:常见CAN错误帧及其排查方向

在本文中主要阐述各类错误帧的形成原因以及在使用同星硬件设备出现错误帧时,应当 如何进行排查并消除错误帧。在 CAN 总线通信中,通常遇见的错误帧主要为以下五种,其 分别是:bit error、ACK error、stuff error、CRC error 以及 form error。

u013089100的博客 1755

QT登录页面跳转至主界面的源代码:实现登录验证的优雅解决方案

QT登录页面跳转至主界面的源代码:实现登录验证的优雅解决方案 去发现同类优质开源项目:https://gitcode.com/ QT登录页面跳转至主界面的源代码,为开发者提供了一个实现用户登录验证功能的基本框架。以下是对该项目的详细介绍,旨在帮助广大开发者理解其核心功能、技术优势及应用场景。 项目介绍 QT登录页面跳转至主界面的源代码,是使用QT框架开发的一款开源软件。它为开发者提供了一个用户友好...

gitblog_06701的博客 681

高斯投影坐标正反算算法(python)

高斯坐标正反算算法,在正算的时候,y的第一个数字表示是用几度带换算的,第二个数字和第三个数字表示带号。该程序是根据武汉大学出版社出版的第三版的《大地测量学基础》编写, 用于课程实验学习。

weixin_64338372的博客 4595

IIC协议常见误区解析:从时序图到实际波形(附逻辑分析仪实测)

本文深入解析IIC协议在实际应用中的常见误区,从理想时序图到逻辑分析仪实测波形的差异,揭示通信故障的根本原因。通过硬件设计优化、软件时序调优和高级调试技巧,帮助开发者有效规避IIC通信中的隐形陷阱,提升系统稳定性。

weixin_28738397的博客 375

QT实现注册登录与界面美化源码

QT实现注册登录与界面美化源码 【下载地址】QT实现注册登录与界面美化源码 本仓库提供了一个基于QT的完整项目源码,涵盖了用户注册登录功能、界面背景图片设置、软键盘输入以及界面跳转等实用功能。通过本项目,您可以学习到如何使用QT框架实现用户认证、数据库操作、界面美化以及交互设计 ...

gitblog_09786的博客 927

【DevOps】rancher集成ldap,实现统一账号登录

登录到rancher控制台,选择【安全】-【认证】 选择【OpenLDAP】 其中【搜索起点】需要去ldap界面查配置完成

CN_Eden 1098

QT登录页面跳转至主界面的源代码

QT登录页面跳转至主界面的源代码 去发现同类优质开源项目:https://gitcode.com/ 本仓库提供了使用QT框架实现登录页面跳转至主界面的源代码。本代码块为开发者提供了一个基本框架,可用于创建具有登录验证功能的应用程序。以下是代码的主要功能和特点: 用户界面友好:基于QT设计,界面简洁,易于用户操作。 登录验证逻辑:实现了登录信息的校验,确保只有合法用户才能访问主界面。 易于扩展:源...

gitblog_06716的博客 356

【教程4>第10章>第13节】基于FPGA的图像双边滤波开发——单通道双边滤波Verilog实现

本文介绍了基于Vivado 2022.2的单通道高斯滤波FPGA实现方案。主要内容包括:1)采用3×3窗口像素提取、高斯权值计算、exp指数运算等模块构建双边滤波系统;2)详细分析了Verilog HDL实现的顶层设计文件,包含窗口数据生成、指数计算、混合权重、归一化处理等关键模块;3)展示了图像双边滤波器的RTL结构图。该设计为后续实现RGB三通道图像高斯滤波及MATLAB联合仿真奠定了基础。

FPGA/MATLAB学习教程/源码/项目合作开发 270

【时时三省】vector cast 常见错误解决/vcast常见错误解决

介绍在使用 vector cast/vcast 软件的过程中,遇到的异常问题。其它异常可以私信解决(购买专栏的前提下)。

时时三省的博客 460

探索QT开发的无限可能:注册登录与界面美化项目推荐

探索QT开发的无限可能:注册登录与界面美化项目推荐 【下载地址】QT实现注册登录与界面美化源码 本仓库提供了一个基于QT的完整项目源码,涵盖了用户注册登录功能、界面背景图片设置、软键盘输入以及界面跳转等实用功能。通过本项目,您可以学习到如何使用QT框架实现用户认证、数据库操作、界面美化以及交互设计 ...

gitblog_09729的博客 651

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

【QT】简单登录跳转界面实现

本系列是作者自学实践过程的记录本文是关于登录界面设计有问题欢迎讨论。

Lee的博客 4052

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

QT-按下按钮实现页面跳转

情景导入 当我们在做应用时,一般都会遇到需要跳转页面的情况,按下一个按钮,跳转到对应的功能界面 ;或者需要进行角色选择,选择不同的角色,进入不同的界面。 今天就用QT简单实现一下上述内容 内容描述 (1)设计三个界面:主界面、用户界面、管理员界面 (2)主界面描述:一个下拉框,实现角色的选择,一个登录按钮,点击后跳转到对应的界面 (3)管理员界面:一个返回按钮,点击后返回主界面 (4)用户界面 :一个返回按钮,点击后返回主界面 效果图 (1)主界面 (2)选择角色 ...

Easadon的博客 1万+

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Qt-多界面编程(界面切换)

在Qt编程中经常遇到多个界面之间的切换, 比如从登录界面跳转到主界面, 主界面跳转到设置界面,在返回到主界面 下面更加这个流程实现一个例子: 1.在QtCreator集成开发环境上创建MultiInterface工程如下(创建工程的时候会自动创建第一个界面命名为LoginWin) 创建完设计好登录界面的UI--可以参考https://blog.csdn.net/tiydy/artic...

tiydy的专栏 6万+

python登陆成功页面跳转_Python QT由登陆界面到主界面

在使用Python QT开发界面的时候,会出现从登陆界面到主界面的一个切换问题。如下所示,用户输入用户名和密码后,如果用户名和密码匹配,则会跳转到主界面,此时登陆界面消失。 首先需要定义自己需要的对话框,请参考:http://blog.csdn.net/lovelyaiq/article/details/55050580。在代码加入对话中加入对话框退出时的返回值,例如:(),()。def save...

weixin_39945531的博客 2787
上一篇: 【2024年度个人生活与博客事业的融合与平衡总结】
下一篇: 【Nomoto 船舶模型】
2345VOR
2345VOR 领域专家: 嵌入式与硬件开发技术领域 领域专家: 嵌入式与硬件开发技术领域
博客等级 码龄9年 4万+粉丝 454原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

2345VOR

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值