[Solved] Virtual void QTableWidget::setModel(QAbstractItemModel*) is private What i do wrong?



  • Hello,

    i have a problem with this Code:

    @QString userEmp = Settings::getUserEmp();
    Database data;
    if(!data.db1Open())
    QMessageBox::critical(this,"Error","Fehler beim öffnen der Datenbank");
    else
    {
    QSqlQuery *qry = new QSqlQuery(data.db1);
    QSqlQueryModel *model = new QSqlQueryModel();
    qry->prepare("SELECT * FROM messageControl WHERE Empfänger = '"+userEmp+"'");
    if(qry->exec())
    {
    model->setQuery(*qry);
    ui->receivedTableWidget->setModel(model);

            data.db1Close();
    
        }
        else
            QMessageBox::critical(this,"Error",qry->lastError().text());
    }@
    

    I have copy the Code from the the same program and paste it in the other Signal. But the Compiler have a problem with this code.

    'virtual void QTableWidget::setModel(QAbstractItemModel*)' is private
    and
    within this context
    @ui->receivedTableWidget->setModel(model);@

    But the other code is right and this code not. What is the problem?

    I hope somebody can help me.

    Bye Alex from Germany


  • Lifetime Qt Champion

    Hi,

    Use a QTableView, QTableWidget has it's own internal model



  • Thanks. It´s works


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.