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. [SOLVED] QTableView - with CustomSortFilterProxyModel - how to get row index recursively without user selection.
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QTableView - with CustomSortFilterProxyModel - how to get row index recursively without user selection.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k 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.
  • R Offline
    R Offline
    roahanramesh
    wrote on last edited by
    #1

    Hi,
    Thanks for taking the time to read my post. I am currently developing a program, where in I use a QTableview with "MySQLQueryModel + CustomSortFilterProxyModel".

    TASK TO ACCOMPLISH:

    Once I finish filtering the data, I need to be able to extract the data from all rows under column 0 (This field contains a unique member ID), from which I can add custom widgets to a layout dynamically.

    ISSUE:
    Right now, I am unable to get the data from any row from column 0. The tableview will be hidden from the user and cannot be viewed.

    Please Help.....

    Thanks and Regards,

    Roahan

    1 Reply Last reply
    0
    • R Offline
      R Offline
      roahanramesh
      wrote on last edited by
      #2

      Solved it myself. Answer was pretty simple. Attaching snippet here.

      this->existingmembermodel = new QSqlQueryModel(this);
      existingmembermodel->setQuery("SELECT * from member_package_current;");
      chmodel = new CheckableProxyModel();
      chmodel->setDynamicSortFilter(true);
      chmodel->setFilterKeyColumn(-1);
      chmodel->setSourceModel(existingmembermodel);

      In textchanged slot of QLineEdit

      QRegExp regExp(arg1);
      chmodel->setFilterRegExp(regExp);
      int rowcount = chmodel->rowCount();
      qDebug()<<"Row Count : "<<chmodel->rowCount();
      for (int i=0;i<rowcount;i++)
      {
      QModelIndex index = chmodel->index(i,0,QModelIndex());
      qDebug()<<"Available Member ID's"<<chmodel->data(index,Qt::DisplayRole).toString();
      }

      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