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. select row from qtableview
Qt 6.11 is out! See what's new in the release blog

select row from qtableview

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 849 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.
  • B Offline
    B Offline
    Bazelboday
    wrote on last edited by Bazelboday
    #1

    hello, i have a problem, here is the code that works fine :
    QSqlQueryModel *model = new QSqlQueryModel(table);
    model->setQuery(QSqlQuery(request, connectionWidget->currentDatabase()));
    table->setModel(model);

    after that i'm trying to read data from second column:

    QModelIndexList indexlist = table->selectionModel()->selectedIndexes();
    qDebug()<< "pls work" << indexlist.count() ;

    and indexlist.count() is zero, but my table have some data, can someone suggest anything? sry for my eng and thanks in advance!i'm trying to solve this whole day..

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bazelboday
      wrote on last edited by
      #2

      table->model()->data(table->model()->index(0,i)).toString(); this works!

      1 Reply Last reply
      1

      • Login

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