【问题标题】:Display data real time in QT c++ from db从 db 在 QT c++ 中实时显示数据
【发布时间】:2020-02-20 00:16:04
【问题描述】:

喜欢this

该项目有一个具有此架构的页面:

整数中有一个 QlineEdit 和一个 texBox(或者可以使用另一个小部件) 我想在文本框中显示数据库的相关单元格(带有查询的sqlite例如:select * frome dbName where code='QlineEdit integer'),但没有按钮操作,实时!

我搜索时可以通过 textchange() 或 QLineEdit::editingFinished() 实现,但不知道如何

【问题讨论】:

    标签: c++ qt signals-slots qt-slot


    【解决方案1】:

    对于以后看到的人来说,它是这样工作的:

    connect(ui->nameLine,SIGNAL(textChanged(QString)),this,
    SLOT(updateLineEditText(QString)));
    
    void MainWindow::updateLineEditText(QString cd) {
    ui->nameLabel->setText("");
    QString textEditString(cd);
    QString flname;
    MainWindow conn;
    conn.connopen();
    QSqlQuery query;
       query.exec("SELECT Firstname, Lastname, Code  FROM Election WHERE Code='"+cd+"'");
       while (query.next()) {
            flname.append( query.value(0).toString() + " ");
            flname.append( query.value(1).toString() + " ");
            ui->nameLabel->setText(flname);
    

    希望有用;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多