QT简单实例

QT简单实例

一:通过拖动创建

在这里插入图片描述

1.创建工程

1.1 新建项目->Application->Qt Widegets Application
1.2 基类->QDialog

2.拖动控件实现响应

2.1 双击 dialog.ui
2.2 拖动 Display Widgets–Label、Input Widgets–Line Edit、Buttons–Push button
在这里插入图片描述
2.3修改控件属性
在这里插入图片描述
2.4最后,修改areaLabel2的“frameShape”为Panel;“frameShadow”为Sunken,如图1.19所示。最终效果如图所示
在这里插入图片描述
2.5添加控件响应函数
1)方式1:在LineEdit文本框内输入半径值,然后单击“计算”按钮,则在areaLabel 2中显示对应的圆面积。编写代码步骤如下。(1)在“计算”按钮上单击鼠标右键,在弹出的下拉菜单中选择“转到槽…”命令,如图1.22所示。在弹出的对话框中选择“clicked()”信号,如图所示,
在这里插入图片描述
2)方式2:在LineEdit内输入半径值,不需要单击按钮触发单击事件,直接就在areaLabel 2中显示圆面积。编写代码步骤如下。(1)在“LineEdit”编辑框上单击鼠标右键,在弹出的下拉菜单中选择“转到槽…”菜单项,在弹出的对话框中选择“textChanged(QString)”信号,如图所示。
在这里插入图片描述

3.文件目录

3.1 TestQDialog.pro
#-------------------------------------------------
#
# Project created by QtCreator 2025-04-15T09:43:14
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TestQDialogSelf
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        dialog.cpp

HEADERS += \
        dialog.h

FORMS += \
        dialog.ui
3.2 main.cpp
#include "dialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Dialog w;
    w.show();
    return a.exec();
}
3.3 dialog.h
#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

protected:
    Ui::Dialog *ui;

protected slots:
    void on_countBtn_clicked();
private slots:
    void on_radiusLineEdit_textChanged(const QString &arg1);
};

#endif // DIALOG_H
3.4 dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    //删除标题栏
    setWindowFlags(Qt::FramelessWindowHint);
    // 背景黑色
    //setStyleSheet("background-color: black;");
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_countBtn_clicked()
{
    const double PI = 3.1416;
    QString str = ui->radiusLineEdit->text();
    int nVal = str.toInt();
    double dArea = PI*nVal*nVal;
    QString strRes;
    strRes.setNum(dArea);
    ui->areaLabel_2->setText(strRes);
}

void Dialog::on_radiusLineEdit_textChanged(const QString &arg1)
{
    const double PI = 3.1416;
    int nVal = arg1.toInt();
    double dArea = nVal*nVal*PI;
    QString strRes;
    ui->areaLabel_2->setText(strRes.setNum(dArea));
}

二:通过动态创建

1.创建工程

1.1 新建项目->Application->Qt Widegets Application
1.2 基类->QDialog

2.文件目录

在这里插入图片描述

2.1 TestQDialogSelf.pro
#-------------------------------------------------
#
# Project created by QtCreator 2025-04-15T09:43:14
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TestQDialogSelf
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp \
        dialog.cpp
HEADERS += \
        dialog.h
FORMS += \
        dialog.ui
2.2 main.cpp
#include "dialog.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Dialog w;
    w.show();
    return a.exec();
}
2.3 dialog.h
#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

protected slots:
    void showArea();
    void showChangeArea(QString str);

protected:
    Ui::Dialog *ui;

protected:
    QLabel* pLabel_1;
    QLabel* pLabel_2;
    QLineEdit* pLineEdit;
    QPushButton* pPushButton;
};
#endif // DIALOG_H
2.4 dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#include <QGridLayout>

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    //去掉标题栏
    setWindowFlags(Qt::FramelessWindowHint);

    //创建控件
    pLabel_1 = new QLabel(this);
    pLabel_1->setText("请输入圆的半径:");
    pLabel_2 = new QLabel(this);
    pLineEdit = new QLineEdit(this);
    pPushButton = new QPushButton(this);
    pPushButton->setText("显示对应圆的面积");

    //创建容器
    QGridLayout* mainLayout = new QGridLayout(this);
    mainLayout->addWidget(pLabel_1,0,0);
    mainLayout->addWidget(pLineEdit,0,1);
    mainLayout->addWidget(pLabel_2,1,0);
    mainLayout->addWidget(pPushButton,1,1);

    //绑定控件响应函数
    connect(pPushButton,SIGNAL(clicked()),this,SLOT(showArea()));
    connect(pLineEdit,SIGNAL(textChanged(QString)),this,SLOT(showChangeArea(QString)));
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::showArea()
{
    const double PI = 3.1416;
    QString str = pLineEdit->text();
    int nVal = str.toInt();
    double dArea = PI*nVal*nVal;
    QString strRes;
    strRes.setNum(dArea);
    pLabel_2->setText(strRes);
}

void Dialog::showChangeArea(QString str)
{
    const double PI = 3.1416;
    int nVal = str.toInt();
    double dArea = PI*nVal*nVal;
    QString strRes;
    strRes.setNum(dArea);
    pLabel_2->setText(strRes);
}

三:功能完善

1.Qt 的自动内存管理机制

在这里插入图片描述
在这里插入图片描述

2.设置字体、背景

QFont gfont;
QPalette gPaletteDlg;
QPalette gPaletteCtl;

void iniBaseParam()
{
    //readIpFile();
    gfont.setFamily("宋体");
    gfont.setPointSize(FONT_SIZE);
    gPaletteDlg.setColor(QPalette::Window, QColor(G_BACKGROUND_C)); // 背景色
    gPaletteDlg.setColor(QPalette::WindowText, QColor(G_FONT_C)); // 文字颜色(可选)
    gPaletteCtl.setColor(QPalette::Base, QColor(G_BACKGROUND_C));      // 背景色
    gPaletteCtl.setColor(QPalette::Text, QColor(G_FONT_C));        // 字体颜色
}

在这里插入图片描述

3.实现键盘(基类)、登录

在这里插入图片描述

3.1 baseDialog.h
#ifndef BASEDIALOG_H
#define BASEDIALOG_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
/////////////////////////////////////////////////////
// 对话框枚举类型
enum DialogType {
    Login_Type
};
/////////////////////////////////////////////////////
#define G_BACKGROUND_C 0xFF000000 //0xFF000000 
#define W_WIDE  400
#define W_HIGH  200
#define W_HIGH_T  250
#define W_X  0
#define W_Y  0

#define G_FONT_C 0xffff00 //255 255 0
#define G_LINE_C 0xCD950C//250 149 12
#define H_LABEL 31
#define FONT_SIZE 20
void iniBaseParam();
//////////////////////////////////////////////////
typedef enum
{
    KEY_1,
    KEY_2,
    KEY_3,
    KEY_4,
    KEY_5,
    KEY_6,
    KEY_7,
    KEY_8,
    KEY_9,
    KEY_UP,
    KEY_0,
    KEY_BACK,
    KEY_LEFT,
    KEY_DOWN,
    KEY_RIGHT,
    KEY_CONFIRM,
    KEY_STATE,
    KEY_SET,
    MAX_KEY_NUM,
} MY_KEY_E;
/////////////////////////////////////////////////

class QBaseDialog : public QWidget
{
    Q_OBJECT
public:
    explicit QBaseDialog(QWidget *parent = nullptr);
    virtual ~QBaseDialog(){}
    DialogType getType(){ return type;}

protected:
    void paintEvent(QPaintEvent *);
    void dlgRaise();
    DialogType  type;

public slots:
    virtual void keyEventSlot(unsigned char key,unsigned char onOff);

public slots:
    void showBtn_1();
    void showBtn_2();
    void showBtn_3();
    void showBtn_4();
    void showBtn_5();
    void showBtn_6();
    void showBtn_7();
    void showBtn_8();
    void showBtn_9();
    void showBtn_0();
    void showBtn_UP();
    void showBtn_DOWN();
    void showBtn_LEFT();
    void showBtn_RIGHT();
    void showBtn_CONFIRM();
    void showBtn_BACK();
    void showBtn_STATE();
    void showBtn_SET();

private:
    void iniBtn();

private:
    QPushButton* pBtn_1;
    QPushButton* pBtn_2;
    QPushButton* pBtn_3;
    QPushButton* pBtn_4;
    QPushButton* pBtn_5;
    QPushButton* pBtn_6;
    QPushButton* pBtn_7;
    QPushButton* pBtn_8;
    QPushButton* pBtn_9;
    QPushButton* pBtn_0;
    QPushButton* pBtn_UP;
    QPushButton* pBtn_DOWN;
    QPushButton* pBtn_LEFT;
    QPushButton* pBtn_RIGHT;
    QPushButton* pBtn_CONFIRM;
    QPushButton* pBtn_BACK;
    QPushButton* pBtn_STATE;
    QPushButton* pBtn_SET;

    QPushButton* pBtn_temp1;
    QPushButton* pBtn_temp2;
};
#endif // BASEDIALOG_H
3.2 baseDialog.cpp
#include <QPainter>
#include "baseDialog.h"
#include <QGridLayout>

QFont gfont;
QPalette gPaletteDlg;
QPalette gPaletteCtl;

void iniBaseParam()
{
    gfont.setFamily("宋体");
    gfont.setPointSize(FONT_SIZE);
    gPaletteDlg.setColor(QPalette::Window, QColor(G_BACKGROUND_C)); // 背景色
    gPaletteDlg.setColor(QPalette::WindowText, QColor(G_FONT_C)); // 文字颜色(可选)
    gPaletteCtl.setColor(QPalette::Base, Qt::yellow);      // 背景色
    gPaletteCtl.setColor(QPalette::Text, Qt::red);        // 字体颜色
}

QBaseDialog::QBaseDialog(QWidget *parent) : QWidget(parent)
{
	//去掉标题栏
    this->setWindowFlags(Qt::FramelessWindowHint);
    // 设置调色板背景色
    this->setPalette(gPaletteDlg);
    //设置位置(x,y,宽,高)
    this->setGeometry(W_X,W_Y,W_WIDE,W_HIGH+W_HIGH_T);

	//初始化键盘设置
    iniBtn();
}

void QBaseDialog::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(QColor(G_LINE_C));
    painter.drawRect(W_X+1, W_Y+1, W_WIDE-3, W_HIGH-10);
    painter.drawRect(W_X+1, W_HIGH, W_WIDE-3, W_HIGH_T-1);
}

void QBaseDialog::dlgRaise()
{
    this->show();          // 1. 显示对话框(如果之前是隐藏的)
    this->raise();         // 2. 将对话框置于其他窗口之上
    this->activateWindow();// 3. 激活窗口(获取焦点)
}
void QBaseDialog::keyEventSlot(unsigned char key,unsigned char onOff)
{
    Q_UNUSED(key);
    Q_UNUSED(onOff);
    qDebug("QBaseDialog::keyEventSlot");
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void QBaseDialog::iniBtn()
{
    pBtn_1 = new QPushButton(this);
    pBtn_1->setText("1");
    pBtn_2 = new QPushButton(this);
    pBtn_2->setText("2");
    pBtn_3 = new QPushButton(this);
    pBtn_3->setText("3");
    pBtn_4 = new QPushButton(this);
    pBtn_4->setText("4");
    pBtn_5 = new QPushButton(this);
    pBtn_5->setText("5");
    pBtn_6 = new QPushButton(this);
    pBtn_6->setText("6");
    pBtn_7 = new QPushButton(this);
    pBtn_7->setText("7");
    pBtn_8 = new QPushButton(this);
    pBtn_8->setText("8");
    pBtn_9 = new QPushButton(this);
    pBtn_9->setText("9");
    pBtn_0 = new QPushButton(this);
    pBtn_0->setText("0");
    pBtn_temp1 = new QPushButton(this);
    pBtn_temp1->setText("*");
    pBtn_temp2 = new QPushButton(this);
    pBtn_temp2->setText("#");
    QLabel*pLable_1 = new QLabel(this);
    pLable_1->setGeometry(W_X+2, W_HIGH+100, W_WIDE-4, W_HIGH_T-100-1);
    pLable_1->setStyleSheet("background-color: white");  // 直接设置背景色
    QGridLayout* pLayout = new QGridLayout(pLable_1);
    pLayout->addWidget(pBtn_1,0,0);
    pLayout->addWidget(pBtn_2,0,1);
    pLayout->addWidget(pBtn_3,0,2);
    pLayout->addWidget(pBtn_4,1,0);
    pLayout->addWidget(pBtn_5,1,1);
    pLayout->addWidget(pBtn_6,1,2);
    pLayout->addWidget(pBtn_7,2,0);
    pLayout->addWidget(pBtn_8,2,1);
    pLayout->addWidget(pBtn_9,2,2);
    pLayout->addWidget(pBtn_temp1,3,0);
    pLayout->addWidget(pBtn_0,3,1);
    pLayout->addWidget(pBtn_temp2,3,2);

    pBtn_UP = new QPushButton(this);
    pBtn_UP->setText("UP");
    pBtn_DOWN = new QPushButton(this);
    pBtn_DOWN->setText("DOWN");
    pBtn_LEFT = new QPushButton(this);
    pBtn_LEFT->setText("LEFT");
    pBtn_RIGHT = new QPushButton(this);
    pBtn_RIGHT->setText("RIGHT");
    pBtn_CONFIRM = new QPushButton(this);
    pBtn_CONFIRM->setText("CONFIRM");
    pBtn_BACK = new QPushButton(this);
    pBtn_BACK->setText("BACK");
    pBtn_STATE = new QPushButton(this);
    pBtn_STATE->setText("STATE");
    pBtn_SET = new QPushButton(this);
    pBtn_SET->setText("SET");

    QLabel*pLable_2 = new QLabel(this);
    pLable_2->setGeometry(W_X+2, W_HIGH+1, W_WIDE-4, 98);
    pLable_2->setStyleSheet("background-color: white");  // 直接设置背景色
    QGridLayout* pLayout_1 = new QGridLayout(pLable_2);
    pLayout_1->addWidget(pBtn_SET,0,0,1,2);
    pLayout_1->addWidget(pBtn_UP,0,3,1,1);
    pLayout_1->addWidget(pBtn_BACK,0,5,1,2);
    pLayout_1->addWidget(pBtn_LEFT,1,2,1,1);
    pLayout_1->addWidget(pBtn_CONFIRM,1,3,1,1);
    pLayout_1->addWidget(pBtn_RIGHT,1,4,1,1);
    pLayout_1->addWidget(pBtn_DOWN,2,3,1,1);
    pLayout_1->addWidget(pBtn_STATE,2,5,1,2);

    //////////////////////////////////////////////////////////////////////////////////
    connect(pBtn_1,SIGNAL(clicked()),this,SLOT(showBtn_1()));
    connect(pBtn_2,SIGNAL(clicked()),this,SLOT(showBtn_2()));
    connect(pBtn_3,SIGNAL(clicked()),this,SLOT(showBtn_3()));
    connect(pBtn_4,SIGNAL(clicked()),this,SLOT(showBtn_4()));
    connect(pBtn_5,SIGNAL(clicked()),this,SLOT(showBtn_5()));
    connect(pBtn_6,SIGNAL(clicked()),this,SLOT(showBtn_6()));
    connect(pBtn_7,SIGNAL(clicked()),this,SLOT(showBtn_7()));
    connect(pBtn_8,SIGNAL(clicked()),this,SLOT(showBtn_8()));
    connect(pBtn_9,SIGNAL(clicked()),this,SLOT(showBtn_9()));
    connect(pBtn_0,SIGNAL(clicked()),this,SLOT(showBtn_0()));
    connect(pBtn_UP,SIGNAL(clicked()),this,SLOT(showBtn_UP()));
    connect(pBtn_DOWN,SIGNAL(clicked()),this,SLOT(showBtn_DOWN()));
    connect(pBtn_LEFT,SIGNAL(clicked()),this,SLOT(showBtn_LEFT()));
    connect(pBtn_RIGHT,SIGNAL(clicked()),this,SLOT(showBtn_RIGHT()));
    connect(pBtn_CONFIRM,SIGNAL(clicked()),this,SLOT(showBtn_CONFIRM()));
    connect(pBtn_BACK,SIGNAL(clicked()),this,SLOT(showBtn_BACK()));
    connect(pBtn_STATE,SIGNAL(clicked()),this,SLOT(showBtn_STATE()));
    connect(pBtn_SET,SIGNAL(clicked()),this,SLOT(showBtn_SET()));
}

void QBaseDialog::showBtn_1()
{
    keyEventSlot(KEY_1,KEY_1);
}

void QBaseDialog::showBtn_2()
{
    keyEventSlot(KEY_2,KEY_2);
}

void QBaseDialog::showBtn_3()
{
    keyEventSlot(KEY_3,KEY_3);
}

void QBaseDialog::showBtn_4()
{
    keyEventSlot(KEY_4,KEY_4);
}

void QBaseDialog::showBtn_5()
{
    keyEventSlot(KEY_5,KEY_5);
}

void QBaseDialog::showBtn_6()
{
    keyEventSlot(KEY_6,KEY_6);
}

void QBaseDialog::showBtn_7()
{
    keyEventSlot(KEY_7,KEY_7);
}

void QBaseDialog::showBtn_8()
{
    keyEventSlot(KEY_8,KEY_8);
}

void QBaseDialog::showBtn_9()
{
    keyEventSlot(KEY_9,KEY_9);
}

void QBaseDialog::showBtn_0()
{
    keyEventSlot(KEY_0,KEY_0);
}

void QBaseDialog::showBtn_UP()
{
    keyEventSlot(KEY_UP,KEY_UP);
}

void QBaseDialog::showBtn_DOWN()
{
    keyEventSlot(KEY_DOWN,KEY_DOWN);
}

void QBaseDialog::showBtn_LEFT()
{
    keyEventSlot(KEY_LEFT,KEY_LEFT);
}

void QBaseDialog::showBtn_RIGHT()
{
    keyEventSlot(KEY_RIGHT,KEY_RIGHT);
}

void QBaseDialog::showBtn_CONFIRM()
{
    keyEventSlot(KEY_CONFIRM,KEY_CONFIRM);
}

void QBaseDialog::showBtn_BACK()
{
    keyEventSlot(KEY_BACK,KEY_BACK);
}

void QBaseDialog::showBtn_STATE()
{
    keyEventSlot(KEY_STATE,KEY_STATE);
}

void QBaseDialog::showBtn_SET()
{
    keyEventSlot(KEY_SET,KEY_SET);
}

注释:QBaseDialog::QBaseDialog中用this->setPalette(gPaletteDlg);而不是this->setStyleSheet(“background-color: black”);因为用setStyleSheet之后会使得后面的控件调用setPalette失败只能用setStyleSheet。

3.3 loginDialog.h
#ifndef LOGINDILAG_H
#define LOGINDILAG_H
#include "baseDialog.h"
#include <QLineEdit>

class QLoginDilag : public QBaseDialog
{
public:
    QLoginDilag();

    void dlgRaise();

public slots:
    void keyEventSlot(unsigned char key,unsigned char onOff);

protected:
    void paintEvent(QPaintEvent *pEvent);

private:
    QLabel *pTimeLab;
    QLineEdit *pPasswordEdit;
    QLineEdit *pNumEdit;
};

#endif // MAINDILAG_H
3.3 loginDialog.cpp
#include <QDebug>
#include "loginDialog.h"
//#include "dialogFactory.h"

//REGISTER_CLASS(Login_Type,QLoginDilag)
QLoginDilag::QLoginDilag()
{
    QLabel *lab[4];
    for(int i=0; i<4; ++i)
    {
        lab[i]=new QLabel(this);
        lab[i]->setFont(gfont);
    }
    lab[0]->setAlignment(Qt::AlignCenter);
    lab[0]->setGeometry(1,1,W_WIDE-2,H_LABEL);
    lab[0]->setText("请输入口令进行登录!");

    lab[1]->setAlignment(Qt::AlignRight);
    lab[1]->setGeometry(1,1+H_LABEL,W_WIDE-80,H_LABEL);
    int nTimes = 6;
    QString message = QString::asprintf("还剩%d次", nTimes );
    lab[1]->setText(message);

    lab[2]->setAlignment(Qt::AlignLeft);
    lab[2]->setGeometry(10,10+H_LABEL*2,80,H_LABEL);
    lab[2]->setText("账号:");
    pPasswordEdit = new QLineEdit(this);
    pPasswordEdit->setFont(gfont);
    pPasswordEdit->setPalette(gPaletteCtl);
    pPasswordEdit->setAlignment(Qt::AlignLeft);
    pPasswordEdit->setGeometry(80,10+H_LABEL*2,W_WIDE-100,H_LABEL);
    pPasswordEdit->setText("*");

    lab[3]->setAlignment(Qt::AlignLeft);
    lab[3]->setGeometry(10,10+H_LABEL*4,80,H_LABEL);
    lab[3]->setText("密码:");
    pNumEdit = new QLineEdit(this);
    pNumEdit->setAlignment(Qt::AlignLeft);
    pNumEdit->setGeometry(80,10+H_LABEL*4,W_WIDE-100,H_LABEL);
    pNumEdit->setText("数:");
}

void QLoginDilag::keyEventSlot(unsigned char key,unsigned char onOff)
{
    Q_UNUSED(onOff);
    qDebug("QLoginDilag=%d\n",key);
    switch(key)
    {
        case KEY_STATE:
        break;
        case KEY_BACK:
        break;
    }
}

void QLoginDilag::paintEvent(QPaintEvent *pEvent)
{
    QBaseDialog::paintEvent(pEvent);
}

3.4 main.cpp
#include <QApplication>
#include "baseDialog.h"
#include "loginDialog.h"

//class Mygpio:public QObject
//{
//	Q_OBJECT

//public:
//    Mygpio();
//     ~Mygpio();
//    bool setSlot(DialogType type);

//signals:
//    void keyMsg(unsigned char,unsigned char);
//private:
//    bool discntSlot(QWidget *w);
//};
//extern Mygpio gMyGpio;
//extern QWidget* gCurDialogPtr ;  // 原始指针
//#endif // KEYBOARD_H
/////////////////////////////////////////////////////

//Mygpio gMyGpio;
//QWidget* gCurDialogPtr = nullptr;  // 原始指针
//bool Mygpio::discntSlot(QWidget *w)
//{
//    disconnect(this,SIGNAL(keyMsg(unsigned char,unsigned char)),w,SLOT(keyEventSlot(unsigned char,unsigned char)));
//    return 0;
//}
//bool Mygpio::setSlot(DialogType type)
//{
//    if(gCurDialogPtr)
//    {
//        discntSlot((QWidget *)gCurDialogPtr);
//        delete gCurDialogPtr;
//        gCurDialogPtr = nullptr;
//    }
//    std::unique_ptr<QBaseDialog> temp = QDialogFactory::getInstance()->create(type);
//    gCurDialogPtr = temp.release();
//    connect(this,SIGNAL(keyMsg(unsigned char,unsigned char)),gCurDialogPtr,SLOT(keyEventSlot(unsigned char,unsigned char)));

//    return 0;
//}


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    /////////////////////////////////////////////////////////
    iniBaseParam();
    /////////////////////////////////////////////////////////
//  gMyGpio.setSlot(Login_Type);
//  gCurDialogPtr->show();
    QLoginDilag *pDlg = new QLoginDilag();
    pDlg->show();
    return a.exec();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值