1.UI设计
(1)登陆界面
(2)注册界面
(3)计算器界面
2.流程图
(1)登录流程图
(2)注册流程图
(2)计算器流程图
3.环境
操作系统:windows10
软件:DeskTop Qt 6.5.3 MSVC2019 64bit
4.测试功能效果
(1)运行后默认登陆界面
1 ui->stackedWidget->setCurrentIndex(0);
(2)点击登陆页面的注册跳转到注册页面(跳转功能参考帮助文档信号和槽)
1 connect(ui->Btn_signup1,&QPushButton::clicked,[=](){ 2 ui->stackedWidget->setCurrentIndex(2); 3 });
(3)点击注册页面的返回跳转到登录页面
1 connect(ui->Btn_return,&QPushButton::clicked,[=](){ 2 ui->stackedWidget->setCurrentIndex(0); 3 });
(4)点击注册界面的注册跳转到登录页面并弹出注册成功消息提示框
1 connect(ui->Btn_singup2,&QPushButton::clicked,[=](){ 2 ui->stackedWidget->setCurrentIndex(0); 3 connect(ui->Btn_singup2,&QPushButton::clicked,[=](){ 4 QMessageBox::information(this,"congratulations","注册成功");
(5)点击登陆页面的登录跳转到计算器页面并弹出登陆成功消息提示框
1 connect(ui->Btn_login,&QPushButton::clicked,[=](){ 2 ui->stackedWidget->setCurrentIndex(1); 3 connect(ui->Btn_login,&QPushButton::clicked,[=](){ 4 //消息提示对话框 5 QMessageBox::information(this,"congratulations","登陆成功");
(6)点击计算器界面的EXIT跳转到登录页面并弹出登录其他账户消息提示框
1 connect(ui->Btn_Exit,&QPushButton::clicked,[=](){ 2 ui->stackedWidget->setCurrentIndex(0); 3 4 }); 5 connect(ui->Btn_Exit,&QPushButton::clicked,[=](){ 6 //消息提示对话框 7 QMessageBox::information(this,"提示","登陆其他账户"); 8 });
5.代码
.pro文件
1 QT += core gui 2 3 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 5 CONFIG += c++17 6 7 # You can make your code fail to compile if it uses deprecated APIs. 8 # In order to do so, uncomment the following line. 9 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 11 SOURCES += \ 12 main.cpp \ 13 widget.cpp 14 15 HEADERS += \ 16 widget.h 17 18 FORMS += \ 19 widget.ui 20 QT +=sql 21 22 # Default rules for deployment. 23 qnx: target.path = /tmp/$${TARGET}/bin 24 else: unix:!android: target.path = /opt/$${TARGET}/bin 25 !isEmpty(target.path): INSTALLS += target
.h文件
1 #ifndef WIDGET_H 2 #define WIDGET_H 3 4 #include <QWidget> 5 #include <QtSql/QSqlDatabase> 6 #include <QDebug> 7 #include <QMessageBox> 8 QT_BEGIN_NAMESPACE 9 namespace Ui { class Widget; } 10 QT_END_NAMESPACE 11 12 class Widget : public QWidget 13 { 14 Q_OBJECT 15 16 public: 17 Widget(QWidget *parent = nullptr); 18 void matchFh();//识别文本的符号与分割 19 ~Widget(); 20 21 private slots: 22 void numOnClick(); 23 void fuHao(); 24 void equalNum(); 25 26 private: 27 Ui::Widget *ui; 28 }; 29 #endif // WIDGET_H
main.cpp
1 #include "widget.h" 2 3 #include <QApplication> 4 5 int main(int argc, char *argv[]) 6 { 7 QApplication a(argc, argv); 8 Widget w; 9 w.show(); 10 return a.exec(); 11 }
.cpp文件
1 #include "widget.h" 2 #include "ui_widget.h" 3 #include <QPushButton> 4 #include <QDebug> 5 #include <QObject> 6 #include <QAction> 7 #include <QDialog> 8 #include <QDebug> 9 #include <QMessageBox> 10 #include <QColorDialog> 11 #include <QFileDialog> 12 #include <QFontDialog> 13 #include <QLineEdit> 14 15 16 QString a; 17 QString b;//定义两个变量,保存用户输入的数字 18 QString texTs;//文本记录变量名 19 bool Add=false; 20 bool Sub=false; 21 bool Mul=false; 22 bool Div=false; 23 24 Widget::Widget(QWidget *parent) 25 : QWidget(parent) 26 , ui(new Ui::Widget) 27 { 28 ui->setupUi(this); 29 QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //这里使用的是MySQL的驱动类型,其他驱动类型可以参考Qt的帮助手册 30 db.setHostName("192.168.107.31");//localhost 31 db.setPort(3306); //默认端口 32 db.setDatabaseName("test"); //用户自建数据库名称 33 db.setUserName("root"); //用户名 34 db.setPassword("1234"); //数据库的密码(如果使用的是MySQL,那就是你登录账号的那个密码) 35 bool ok = db.open(); //定义一个标志量,返回数据库连接状态 36 if (ok){ 37 QMessageBox::information(this, "infor", "success"); 38 } 39 else { 40 QMessageBox::information(this, "infor", "open failed"); 41 } 42 43 44 //设置窗口名称 45 this->setWindowTitle("计算器"); 46 //设置文本框初始状态为空 47 ui->plainTextEdit->setPlainText(""); 48 //获取当前文本框给text 49 texTs = ui->plainTextEdit->toPlainText(); 50 QPushButton *numbuttons[11];//定义大小为11的数组存放按钮对象 51 for(int k=0;k<11;k++) 52 { 53 QString numName = "Btn_"+QString::number(k); 54 numbuttons[k] = Widget::findChild<QPushButton *>(numName); 55 connect(numbuttons[k],SIGNAL(clicked(bool)),this,SLOT(numOnClick())); 56 } 57 connect(ui->Btn_Add,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 58 connect(ui->Btn_Sub,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 59 connect(ui->Btn_Mul,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 60 connect(ui->Btn_Div,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 61 connect(ui->Btn_Sqrt,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 62 connect(ui->Btn_Clear,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 63 connect(ui->Btn_Dle,SIGNAL(clicked(bool)),this,SLOT(fuHao())); 64 connect(ui->Btn_Wait,SIGNAL(clicked(bool)),this,SLOT(equalNum())); 65 66 //设置默认定位 登陆页面 67 ui->stackedWidget->setCurrentIndex(0); 68 //点击登陆页面的注册跳转到注册页面 69 connect(ui->Btn_signup1,&QPushButton::clicked,[=](){ 70 ui->stackedWidget->setCurrentIndex(2); 71 }); 72 //点击登陆页面的登录跳转到计算器页面 73 connect(ui->Btn_login,&QPushButton::clicked,[=](){ 74 ui->stackedWidget->setCurrentIndex(1); 75 }); 76 //点击注册页面的返回跳转到登录页面 77 connect(ui->Btn_return,&QPushButton::clicked,[=](){ 78 ui->stackedWidget->setCurrentIndex(0); 79 }); 80 //点击注册界面的注册跳转到登录页面 81 connect(ui->Btn_singup2,&QPushButton::clicked,[=](){ 82 ui->stackedWidget->setCurrentIndex(0); 83 qDebug()<<"注册成功"; 84 }); 85 //点击计算器界面的EXIT跳转到登录页面 86 connect(ui->Btn_Exit,&QPushButton::clicked,[=](){ 87 ui->stackedWidget->setCurrentIndex(0); 88 89 }); 90 //点击注册界面的注册按钮 弹出消息注册成功 91 connect(ui->Btn_singup2,&QPushButton::clicked,[=](){ 92 //消息提示对话框 93 QMessageBox::information(this,"congratulations","注册成功"); 94 }); 95 //点击登录界面的登录按钮 弹出消息登录成功 96 connect(ui->Btn_login,&QPushButton::clicked,[=](){ 97 //消息提示对话框 98 QMessageBox::information(this,"congratulations","登陆成功"); 99 }); 100 //点击计算器界面的EXIT按钮 弹出消息登录其他账户 101 connect(ui->Btn_Exit,&QPushButton::clicked,[=](){ 102 //消息提示对话框 103 QMessageBox::information(this,"提示","登陆其他账户"); 104 }); 105 } 106 107 Widget::~Widget() 108 { 109 delete ui; 110 } 111 112 void Widget::numOnClick() 113 { 114 QPushButton *numName = (QPushButton*)sender();//sender返回信号来源的对象 115 ui->plainTextEdit->textCursor().insertText(numName->text()); 116 texTs = ui->plainTextEdit->toPlainText(); 117 if(Add) 118 { 119 int i = texTs.indexOf("+"); 120 texTs = texTs.mid(i+1); 121 b = texTs; 122 } 123 if(Sub) 124 { 125 int i = texTs.indexOf("-"); 126 texTs = texTs.mid(i+1); 127 b = texTs; 128 } 129 if(Mul) 130 { 131 int i = texTs.indexOf("*"); 132 texTs = texTs.mid(i+1); 133 b = texTs; 134 } 135 if(Div) 136 { 137 int i = texTs.indexOf("/"); 138 texTs = texTs.mid(i+1); 139 b = texTs; 140 } 141 else a=texTs; 142 qDebug() << a << b; 143 } 144 void Widget::fuHao() 145 { 146 QPushButton *fh = (QPushButton*)sender();//sender返回信号来源的对象 147 QString f = fh->text(); 148 if(!(Add||Sub||Mul||Div))//只限定输入一个运算符 149 { 150 if(f == "+") 151 { 152 Add = true; 153 ui->plainTextEdit->textCursor().insertText("+"); 154 } 155 if(f == "-") 156 { 157 Sub = true; 158 ui->plainTextEdit->textCursor().insertText("-"); 159 } 160 if(f == "*") 161 { 162 Mul = true; 163 ui->plainTextEdit->textCursor().insertText("*"); 164 } 165 if(f == "/") 166 { 167 Div = true; 168 ui->plainTextEdit->textCursor().insertText("/"); 169 } 170 } 171 172 if(f =="C") 173 { 174 a=b=0; 175 Add=Sub=Mul=Div=false; 176 ui->plainTextEdit->setPlainText(""); 177 } 178 if(f =="×") 179 { 180 texTs = ui->plainTextEdit->toPlainText(); 181 texTs.chop(1); 182 Add=Sub=Mul=Div=false; 183 matchFh(); 184 ui->plainTextEdit->setPlainText(texTs); 185 ui->plainTextEdit->moveCursor(QTextCursor::End); 186 } 187 } 188 189 void Widget::matchFh()//识别文本的符号与分割 190 { 191 if(texTs.contains("+",Qt::CaseInsensitive))//检测输入文本是否有"+"号 192 { 193 QStringList t = texTs.split("+"); 194 a = t[0]; 195 b = t[1]; 196 Add = true; 197 } 198 else if(texTs.contains("-",Qt::CaseInsensitive))//检测输入文本是否有"-"号 199 { 200 QStringList t = texTs.split("-"); 201 a = t[0]; 202 b = t[1]; 203 Sub = true; 204 } 205 else if(texTs.contains("*",Qt::CaseInsensitive))//检测输入文本是否有"*"号 206 { 207 QStringList t = texTs.split("*"); 208 a = t[0]; 209 b = t[1]; 210 Mul = true; 211 } 212 else if(texTs.contains("/",Qt::CaseInsensitive))//检测输入文本是否有"/"号 213 { 214 QStringList t = texTs.split("/"); 215 a = t[0]; 216 b = t[1]; 217 Div = true; 218 } 219 else a=texTs; 220 221 } 222 void Widget::equalNum() 223 { 224 double x; 225 double y; 226 texTs = ui->plainTextEdit->toPlainText(); 227 matchFh(); 228 x = a.toDouble(); 229 y = b.toDouble(); 230 qDebug()<<"x:"<<x<<"y:"<<y; 231 if(Add) 232 { 233 ui->plainTextEdit->setPlainText(a=QString::number(x+y)); 234 Add = false; 235 } 236 if(Sub) 237 { 238 ui->plainTextEdit->setPlainText(a=QString::number(x-y)); 239 Sub = false; 240 } 241 if(Mul) 242 { 243 ui->plainTextEdit->setPlainText(a=QString::number(x*y)); 244 Mul = false; 245 } 246 if(Div) 247 { 248 ui->plainTextEdit->setPlainText(a=QString::number(x/y)); 249 Div = false; 250 } 251 252 253 ui->plainTextEdit->moveCursor(QTextCursor::End); 254 }View Code
.ui文件
1 <?xml version="1.0" encoding="UTF-8"?> 2 <ui version="4.0"> 3 <class>Widget</class> 4 <widget class="QWidget" name="Widget"> 5 <property name="geometry"> 6 <rect> 7 <x>0</x> 8 <y>0</y> 9 <width>473</width> 10 <height>299</height> 11 </rect> 12 </property> 13 <property name="windowTitle"> 14 <string>Widget</string> 15 </property> 16 <layout class="QVBoxLayout" name="verticalLayout"> 17 <item> 18 <widget class="QStackedWidget" name="stackedWidget"> 19 <property name="sizePolicy"> 20 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 21 <horstretch>0</horstretch> 22 <verstretch>0</verstretch> 23 </sizepolicy> 24 </property> 25 <property name="currentIndex"> 26 <number>1</number> 27 </property> 28 <widget class="QWidget" name="page1"> 29 <widget class="QWidget" name="widget" native="true"> 30 <property name="geometry"> 31 <rect> 32 <x>10</x> 33 <y>20</y> 34 <width>586</width> 35 <height>116</height> 36 </rect> 37 </property> 38 <property name="sizePolicy"> 39 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> 40 <horstretch>0</horstretch> 41 <verstretch>0</verstretch> 42 </sizepolicy> 43 </property> 44 <layout class="QGridLayout" name="gridLayout"> 45 <item row="2" column="1"> 46 <widget class="QLabel" name="label_2"> 47 <property name="text"> 48 <string>密 码:</string> 49 </property> 50 </widget> 51 </item> 52 <item row="0" column="3"> 53 <spacer name="horizontalSpacer_2"> 54 <property name="orientation"> 55 <enum>Qt::Horizontal</enum> 56 </property> 57 <property name="sizeHint" stdset="0"> 58 <size> 59 <width>40</width> 60 <height>20</height> 61 </size> 62 </property> 63 </spacer> 64 </item> 65 <item row="0" column="2"> 66 <widget class="QLineEdit" name="lineEdit"/> 67 </item> 68 <item row="0" column="0"> 69 <spacer name="horizontalSpacer"> 70 <property name="orientation"> 71 <enum>Qt::Horizontal</enum> 72 </property> 73 <property name="sizeType"> 74 <enum>QSizePolicy::Fixed</enum> 75 </property> 76 <property name="sizeHint" stdset="0"> 77 <size> 78 <width>90</width> 79 <height>20</height> 80 </size> 81 </property> 82 </spacer> 83 </item> 84 <item row="2" column="2"> 85 <widget class="QLineEdit" name="lineEdit_2"/> 86 </item> 87 <item row="0" column="1"> 88 <widget class="QLabel" name="label"> 89 <property name="text"> 90 <string>用户名:</string> 91 </property> 92 </widget> 93 </item> 94 <item row="1" column="2"> 95 <spacer name="verticalSpacer"> 96 <property name="orientation"> 97 <enum>Qt::Vertical</enum> 98 </property> 99 <property name="sizeType"> 100 <enum>QSizePolicy::Fixed</enum> 101 </property> 102 <property name="sizeHint" stdset="0"> 103 <size> 104 <width>20</width> 105 <height>40</height> 106 </size> 107 </property> 108 </spacer> 109 </item> 110 </layout> 111 </widget> 112 <widget class="QWidget" name="widget_2" native="true"> 113 <property name="geometry"> 114 <rect> 115 <x>40</x> 116 <y>200</y> 117 <width>586</width> 118 <height>42</height> 119 </rect> 120 </property> 121 <property name="sizePolicy"> 122 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> 123 <horstretch>0</horstretch> 124 <verstretch>0</verstretch> 125 </sizepolicy> 126 </property> 127 <layout class="QHBoxLayout" name="horizontalLayout"> 128 <item> 129 <spacer name="horizontalSpacer_3"> 130 <property name="orientation"> 131 <enum>Qt::Horizontal</enum> 132 </property> 133 <property name="sizeType"> 134 <enum>QSizePolicy::Fixed</enum> 135 </property> 136 <property name="sizeHint" stdset="0"> 137 <size> 138 <width>35</width> 139 <height>20</height> 140 </size> 141 </property> 142 </spacer> 143 </item> 144 <item> 145 <widget class="QPushButton" name="Btn_login"> 146 <property name="text"> 147 <string>登录</string> 148 </property> 149 </widget> 150 </item> 151 <item> 152 <spacer name="horizontalSpacer_5"> 153 <property name="orientation"> 154 <enum>Qt::Horizontal</enum> 155 </property> 156 <property name="sizeHint" stdset="0"> 157 <size> 158 <width>40</width> 159 <height>20</height> 160 </size> 161 </property> 162 </spacer> 163 </item> 164 <item> 165 <widget class="QPushButton" name="Btn_signup1"> 166 <property name="text"> 167 <string>注册</string> 168 </property> 169 </widget> 170 </item> 171 <item> 172 <spacer name="horizontalSpacer_4"> 173 <property name="orientation"> 174 <enum>Qt::Horizontal</enum> 175 </property> 176 <property name="sizeHint" stdset="0"> 177 <size> 178 <width>40</width> 179 <height>20</height> 180 </size> 181 </property> 182 </spacer> 183 </item> 184 </layout> 185 </widget> 186 </widget> 187 <widget class="QWidget" name="page"> 188 <layout class="QVBoxLayout" name="verticalLayout_3"> 189 <item> 190 <widget class="QPlainTextEdit" name="plainTextEdit"/> 191 </item> 192 <item> 193 <widget class="QWidget" name="widget_5" native="true"> 194 <property name="sizePolicy"> 195 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 196 <horstretch>0</horstretch> 197 <verstretch>0</verstretch> 198 </sizepolicy> 199 </property> 200 <layout class="QGridLayout" name="gridLayout_3"> 201 <item row="2" column="2"> 202 <widget class="QPushButton" name="Btn_9"> 203 <property name="text"> 204 <string>9</string> 205 </property> 206 </widget> 207 </item> 208 <item row="2" column="3" colspan="2"> 209 <widget class="QPushButton" name="Btn_Clear"> 210 <property name="text"> 211 <string>C</string> 212 </property> 213 </widget> 214 </item> 215 <item row="0" column="4"> 216 <widget class="QPushButton" name="Btn_Add"> 217 <property name="text"> 218 <string>+</string> 219 </property> 220 </widget> 221 </item> 222 <item row="1" column="0"> 223 <widget class="QPushButton" name="Btn_4"> 224 <property name="text"> 225 <string>4</string> 226 </property> 227 </widget> 228 </item> 229 <item row="1" column="1"> 230 <widget class="QPushButton" name="Btn_5"> 231 <property name="text"> 232 <string>5</string> 233 </property> 234 </widget> 235 </item> 236 <item row="3" column="1"> 237 <widget class="QPushButton" name="Btn_0"> 238 <property name="text"> 239 <string>0</string> 240 </property> 241 </widget> 242 </item> 243 <item row="3" column="5"> 244 <widget class="QPushButton" name="Btn_Exit"> 245 <property name="text"> 246 <string>Exit</string> 247 </property> 248 </widget> 249 </item> 250 <item row="1" column="4"> 251 <widget class="QPushButton" name="Btn_Mul"> 252 <property name="text"> 253 <string>*</string> 254 </property> 255 </widget> 256 </item> 257 <item row="3" column="0"> 258 <widget class="QPushButton" name="Btn_10"> 259 <property name="text"> 260 <string>.</string> 261 </property> 262 </widget> 263 </item> 264 <item row="2" column="0"> 265 <widget class="QPushButton" name="Btn_7"> 266 <property name="text"> 267 <string>7</string> 268 </property> 269 </widget> 270 </item> 271 <item row="0" column="1"> 272 <widget class="QPushButton" name="Btn_2"> 273 <property name="text"> 274 <string>2</string> 275 </property> 276 </widget> 277 </item> 278 <item row="2" column="5"> 279 <widget class="QPushButton" name="Btn_Dle"> 280 <property name="text"> 281 <string>×</string> 282 </property> 283 </widget> 284 </item> 285 <item row="3" column="3" colspan="2"> 286 <widget class="QPushButton" name="Btn_Wait"> 287 <property name="text"> 288 <string>=</string> 289 </property> 290 </widget> 291 </item> 292 <item row="0" column="0"> 293 <widget class="QPushButton" name="Btn_1"> 294 <property name="text"> 295 <string>1</string> 296 </property> 297 </widget> 298 </item> 299 <item row="3" column="2"> 300 <widget class="QPushButton" name="Btn_Sqrt"> 301 <property name="text"> 302 <string>sqrt</string> 303 </property> 304 </widget> 305 </item> 306 <item row="1" column="2"> 307 <widget class="QPushButton" name="Btn_6"> 308 <property name="text"> 309 <string>6</string> 310 </property> 311 </widget> 312 </item> 313 <item row="1" column="5"> 314 <widget class="QPushButton" name="Btn_Div"> 315 <property name="text"> 316 <string>/</string> 317 </property> 318 </widget> 319 </item> 320 <item row="0" column="5"> 321 <widget class="QPushButton" name="Btn_Sub"> 322 <property name="text"> 323 <string>-</string> 324 </property> 325 </widget> 326 </item> 327 <item row="0" column="2"> 328 <widget class="QPushButton" name="Btn_3"> 329 <property name="text"> 330 <string>3</string> 331 </property> 332 </widget> 333 </item> 334 <item row="2" column="1"> 335 <widget class="QPushButton" name="Btn_8"> 336 <property name="text"> 337 <string>8</string> 338 </property> 339 </widget> 340 </item> 341 </layout> 342 </widget> 343 </item> 344 </layout> 345 </widget> 346 <widget class="QWidget" name="page2"> 347 <layout class="QVBoxLayout" name="verticalLayout_2"> 348 <item> 349 <widget class="QWidget" name="widget_3" native="true"> 350 <layout class="QGridLayout" name="gridLayout_2"> 351 <item row="4" column="2"> 352 <widget class="QLineEdit" name="lineEdit_5"/> 353 </item> 354 <item row="9" column="2"> 355 <spacer name="horizontalSpacer_12"> 356 <property name="orientation"> 357 <enum>Qt::Horizontal</enum> 358 </property> 359 <property name="sizeHint" stdset="0"> 360 <size> 361 <width>40</width> 362 <height>20</height> 363 </size> 364 </property> 365 </spacer> 366 </item> 367 <item row="0" column="1"> 368 <widget class="QLabel" name="label_3"> 369 <property name="text"> 370 <string>用 户 名:</string> 371 </property> 372 </widget> 373 </item> 374 <item row="1" column="2"> 375 <spacer name="verticalSpacer_2"> 376 <property name="orientation"> 377 <enum>Qt::Vertical</enum> 378 </property> 379 <property name="sizeHint" stdset="0"> 380 <size> 381 <width>20</width> 382 <height>40</height> 383 </size> 384 </property> 385 </spacer> 386 </item> 387 <item row="2" column="2"> 388 <widget class="QLineEdit" name="lineEdit_4"/> 389 </item> 390 <item row="6" column="1"> 391 <widget class="QLabel" name="label_6"> 392 <property name="text"> 393 <string>确认密码:</string> 394 </property> 395 </widget> 396 </item> 397 <item row="8" column="1"> 398 <widget class="QLabel" name="label_7"> 399 <property name="text"> 400 <string>验 证 码:</string> 401 </property> 402 </widget> 403 </item> 404 <item row="8" column="2"> 405 <widget class="QLineEdit" name="lineEdit_7"/> 406 </item> 407 <item row="4" column="3"> 408 <spacer name="horizontalSpacer_10"> 409 <property name="orientation"> 410 <enum>Qt::Horizontal</enum> 411 </property> 412 <property name="sizeHint" stdset="0"> 413 <size> 414 <width>40</width> 415 <height>20</height> 416 </size> 417 </property> 418 </spacer> 419 </item> 420 <item row="6" column="2"> 421 <widget class="QLineEdit" name="lineEdit_6"/> 422 </item> 423 <item row="2" column="1"> 424 <widget class="QLabel" name="label_4"> 425 <property name="text"> 426 <string>邮 箱:</string> 427 </property> 428 </widget> 429 </item> 430 <item row="0" column="2"> 431 <widget class="QLineEdit" name="lineEdit_3"/> 432 </item> 433 <item row="3" column="2"> 434 <spacer name="verticalSpacer_3"> 435 <property name="orientation"> 436 <enum>Qt::Vertical</enum> 437 </property> 438 <property name="sizeHint" stdset="0"> 439 <size> 440 <width>20</width> 441 <height>40</height> 442 </size> 443 </property> 444 </spacer> 445 </item> 446 <item row="4" column="1"> 447 <widget class="QLabel" name="label_5"> 448 <property name="text"> 449 <string>密 码:</string> 450 </property> 451 </widget> 452 </item> 453 <item row="7" column="2"> 454 <spacer name="verticalSpacer_4"> 455 <property name="orientation"> 456 <enum>Qt::Vertical</enum> 457 </property> 458 <property name="sizeHint" stdset="0"> 459 <size> 460 <width>20</width> 461 <height>40</height> 462 </size> 463 </property> 464 </spacer> 465 </item> 466 <item row="4" column="0"> 467 <spacer name="horizontalSpacer_9"> 468 <property name="orientation"> 469 <enum>Qt::Horizontal</enum> 470 </property> 471 <property name="sizeType"> 472 <enum>QSizePolicy::Fixed</enum> 473 </property> 474 <property name="sizeHint" stdset="0"> 475 <size> 476 <width>115</width> 477 <height>20</height> 478 </size> 479 </property> 480 </spacer> 481 </item> 482 <item row="5" column="2"> 483 <spacer name="verticalSpacer_5"> 484 <property name="orientation"> 485 <enum>Qt::Vertical</enum> 486 </property> 487 <property name="sizeHint" stdset="0"> 488 <size> 489 <width>20</width> 490 <height>40</height> 491 </size> 492 </property> 493 </spacer> 494 </item> 495 </layout> 496 </widget> 497 </item> 498 <item> 499 <widget class="QWidget" name="widget_4" native="true"> 500 <layout class="QHBoxLayout" name="horizontalLayout_4"> 501 <item> 502 <spacer name="horizontalSpacer_6"> 503 <property name="orientation"> 504 <enum>Qt::Horizontal</enum> 505 </property> 506 <property name="sizeType"> 507 <enum>QSizePolicy::Fixed</enum> 508 </property> 509 <property name="sizeHint" stdset="0"> 510 <size> 511 <width>105</width> 512 <height>20</height> 513 </size> 514 </property> 515 </spacer> 516 </item> 517 <item> 518 <widget class="QPushButton" name="Btn_singup2"> 519 <property name="text"> 520 <string>注册</string> 521 </property> 522 </widget> 523 </item> 524 <item> 525 <spacer name="horizontalSpacer_8"> 526 <property name="orientation"> 527 <enum>Qt::Horizontal</enum> 528 </property> 529 <property name="sizeHint" stdset="0"> 530 <size> 531 <width>40</width> 532 <height>20</height> 533 </size> 534 </property> 535 </spacer> 536 </item> 537 <item> 538 <widget class="QPushButton" name="Btn_return"> 539 <property name="text"> 540 <string>返回</string> 541 </property> 542 </widget> 543 </item> 544 <item> 545 <spacer name="horizontalSpacer_7"> 546 <property name="orientation"> 547 <enum>Qt::Horizontal</enum> 548 </property> 549 <property name="sizeHint" stdset="0"> 550 <size> 551 <width>40</width> 552 <height>20</height> 553 </size> 554 </property> 555 </spacer> 556 </item> 557 </layout> 558 </widget> 559 </item> 560 </layout> 561 </widget> 562 </widget> 563 </item> 564 </layout> 565 </widget> 566 <resources/> 567 <connections/> 568 </ui>View Code
6.主要问题
(1)数据库连接
注:参考自 知乎 @Qt编程技术专家
csdn @别打名名
51CT0 (转载) @mob64ca140d96d9
阿里云开发者社区 @geekori
遇到问题
代码连接失败
运行后
下载ODBC64bit
连接失败
标签:clicked,计算机,connect,texTs,ui,登陆,界面,Btn,Qt From: https://www.cnblogs.com/244-385-205/p/17877969.html