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?
QtWS25 Last Chance

Cannot access private member?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.4k Views
  • 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.
  • R Offline
    R Offline
    Rust
    wrote on 30 May 2016, 18:24 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! =)

    J 1 Reply Last reply 30 May 2016, 18:29
    0
    • R Rust
      30 May 2016, 18:24

      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! =)

      J Offline
      J Offline
      Joel Bodenmann
      wrote on 30 May 2016, 18:29 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
      • R Offline
        R Offline
        Rust
        wrote on 30 May 2016, 18:33 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

        1/3

        30 May 2016, 18:24

        • Login

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