Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot access private member?
Forum Updated to NodeBB v4.3 + New Features

Cannot access private member?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.6k 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.
  • RustR Offline
    RustR Offline
    Rust
    wrote on last edited by Rust
    #1

    I have this trigger function for a Window i created:

    void MainWindow::on_searchProdutos_textChanged()
    {
    QSqlQuery* qry = new QSqlQuery(DATABASE_NAME);
    QSqlQueryModel* modal = new QSqlQueryModel;

    qry->prepare("select * from clientes");
    qry->exec();
    
    modal->setQuery(*qry);
    
    ui->listProdutos->setModel(modal);
    
    
    return;
    

    }

    And the compiler gives me the following error...
    64: error: C2248: 'QListWidget::setModel': cannot access private member declared in class 'QListWidget'

    I've already coded several functions like these already, why is it erroring out here?

    Thanks in advance for any help! =)

    Joel BodenmannJ 1 Reply Last reply
    0
    • RustR Rust

      I have this trigger function for a Window i created:

      void MainWindow::on_searchProdutos_textChanged()
      {
      QSqlQuery* qry = new QSqlQuery(DATABASE_NAME);
      QSqlQueryModel* modal = new QSqlQueryModel;

      qry->prepare("select * from clientes");
      qry->exec();
      
      modal->setQuery(*qry);
      
      ui->listProdutos->setModel(modal);
      
      
      return;
      

      }

      And the compiler gives me the following error...
      64: error: C2248: 'QListWidget::setModel': cannot access private member declared in class 'QListWidget'

      I've already coded several functions like these already, why is it erroring out here?

      Thanks in advance for any help! =)

      Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by Joel Bodenmann
      #2

      It looks like your listProdutos is a QListWidget instead of a QListView. If you want to work with the model/view concept you want to use just the plain QListView. The QListWidget is a convenience widget that merges a QListView and a corresponding model into one widget. The model in that widget is a private attribute and thus you get the error that you are not allowed to access that member.

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      1 Reply Last reply
      2
      • RustR Offline
        RustR Offline
        Rust
        wrote on last edited by Rust
        #3

        It now doesn't cause any error anymore. I checked the attributes at Qt's qt 5.6 page, but was checking indeed for QListView, instead of QListWidget so wasn't figuring out what the issue was.
        Thank you for that! =)

        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