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. Data of QTreeView rows
Forum Updated to NodeBB v4.3 + New Features

Data of QTreeView rows

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

    I made a QTreeView with a QStandardItemModel to show some data from a MySQL query as a list and it's working fine. Now I need to get the 'double-click' signal from the QTreeView rows, and fill 3 QLineEdit with the data from the row clicked. How do I get the data from the 'double-clicked' row?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You connect a slot to signal "doubleClicked() ":http://doc.qt.nokia.com/4.7/qabstractitemview.html#doubleClicked. The model index contains parent, row and column of the model index clicked. In your slot, you can get the current values via

      @
      int row = index.row();
      QModelIndex parent = index.parent();
      QString str0 = model->data(model->index(row, 0, parent), Qt::EditRole);
      QString str1 = model->data(model->index(row, 1, parent), Qt::EditRole);
      QString str2 = model->data(model->index(row, 2, parent), Qt::EditRole);
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      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