Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. [Solved] Virtual void QTableWidget::setModel(QAbstractItemModel*) is private What i do wrong?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Language Bindings
3 Posts 2 Posters 9.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nickvan86
    wrote on last edited by
    #1

    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

    Qt 5.2.1 Creator 3.0.1 Windows 7 64bit

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nickvan86
        wrote on last edited by
        #3

        Thanks. It´s works

        Qt 5.2.1 Creator 3.0.1 Windows 7 64bit

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved