为什么qt登录不上去QT语音总是停留在登录窗口。登不上去。 是怎么回事。

为什么qt登录不上去QT语音总是停留在登录窗口。登不上去。 是怎么回事。,第1张

网络有问题耐心等待
上述回答采纳不采纳,我不强求 ,
只求能帮助到楼主。
若需要帮助,本人可为您效仿。
远程帮助为您排难解忧解决你的担心的问题
若回答不准确可以追问 我们可以互相探讨下。
小女子,祝您合家欢乐,心想事成。
万事顺心
谢谢!

function getGithunZen() {
var url = ">

供参考:

maincpp 文件

#include <QApplication>
#include "clogindialogh"
int main(int argc, char argv[])
{
    QApplication app(argc, argv);
    CLoginDialog loginDlg = new CLoginDialog();
    loginDlg->show();
    return appexec();
}

clogindialogh 文件

#ifndef CLOGINDIALOG_H
#define CLOGINDIALOG_H
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QComboBox>
#include <QLayout>
class CLoginDialog : public QDialog
{
    Q_OBJECT
public:
    explicit CLoginDialog(QWidget parent = nullptr);
private slots:
    void showMainWindow();
private:
    QComboBox userTypeCombo;
};
#endif // CLOGINDIALOG_H

clogindialogcpp 文件

#include "clogindialogh"
#include "cwidgetah"
#include "cwidgetbh"
CLoginDialog::CLoginDialog(QWidget parent) : QDialog(parent)
{
    QHBoxLayout lineLayout1 = new QHBoxLayout();
    lineLayout1->addWidget(new QLabel(tr("登录类型")));
    userTypeCombo = new QComboBox();
    userTypeCombo->addItem(tr("教师"),0);
    userTypeCombo->addItem(tr("学生"),1);
    lineLayout1->addWidget(userTypeCombo);
    QHBoxLayout lineLayout2 = new QHBoxLayout();
    lineLayout2->addStretch();
    QPushButton loginBt = new QPushButton(tr("登录"));
    connect(loginBt,&QPushButton::clicked,this,&CLoginDialog::showMainWindow);
    lineLayout2->addWidget(loginBt);
    QVBoxLayout mainLayout = new QVBoxLayout();
    mainLayout->addLayout(lineLayout1);
    mainLayout->addLayout(lineLayout2);
    setLayout(mainLayout);
}
void CLoginDialog::showMainWindow()
{
    if(userTypeCombo->currentData() == 0){
        CWidgetA a = new CWidgetA();
        a->show();
    }else{
        CWidgetB b = new CWidgetB();
        b->show();
    }
    close();
}

cwidgetah 文件

#ifndef CWIDGETA_H
#define CWIDGETA_H
#include <QMainWindow>
class CWidgetA : public QMainWindow
{
    Q_OBJECT
public:
    explicit CWidgetA(QWidget parent = nullptr);
};
#endif // CWIDGETA_H

cwidgetacpp 文件

#include "cwidgetah"
#include <QLabel>
CWidgetA::CWidgetA(QWidget parent) : QMainWindow(parent)
{
    setCentralWidget(new QLabel(tr("这是窗口A")));
}

cwidgetbh


#ifndef CWIDGETB_H
#define CWIDGETB_H
#include <QMainWindow>
class CWidgetB : public QMainWindow
{
    Q_OBJECT
public:
    explicit CWidgetB(QWidget parent = nullptr);
};
#endif // CWIDGETB_H

cwidgetbcpp

#include "cwidgetbh"
#include <QLabel>
CWidgetB::CWidgetB(QWidget parent) : QMainWindow(parent)
{
     setCentralWidget(new QLabel(tr("这是窗口B")));
}

if (false == ui->LineEdit->text()isEmpty()){
    //允许登录
}
else{
    QMessageBox::warning(this, tr("WindowTitle"), tr("Empty Input String"));
}

用QLineEdit控件作为密码输入的话参照上面代码即可。

/以下是登录成功,并判断checkbox是否选择记录本次登录信息/if(0==keycompare(User_Info[i]key,Qt::CaseSensitive)){//checkIn();if(Qt::Checked==box->checkState()){QFilef("/userdat");fopen(QIODevice::WriteOnly);QDataStreamout(&f);outsetVersion(QDataStream::Qt_4_4);out>tmp_username>>tmp_userkey;fileclose();}nameedit->setText(tmp_username);keyedit->setText(tmp_userkey);/你也可以选择自己喜欢的登录信息保存方式,这个可能还涉及到安全性保密性等问题,不过大概的方法应该就是这样子,希望能帮到你。/


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13176015.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-06-16
下一篇 2023-06-16

发表评论

登录后才能评论

评论列表(0条)

保存