Results 1 to 5 of 5

Thread: How to get all column data from a single row with a QTableView and doubleclick

  1. #1
    Join Date
    Jul 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default How to get all column data from a single row with a QTableView and doubleclick

    Hello
    I was wondering if anyone could tell me the best way to get and display all the column data from a tableview, i currently have a model and pass it to the qtableview and i have used the doubleclick signal/slot to display a field when a column is clicked using the index. So for example if i have a 3 columns in a row "firstname" "middlename" "lastname" and i click the first firstname column in the view my slot displays the name i just clicked on with qdebug, but i need it to display all 3 fields from the row. Does anyone know the best way to make this work? Any help would be appreciated thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get all column data from a single row with a QTableView and doubleclick

    Where do you want to display the values?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: How to get all column data from a single row with a QTableView and doubleclick

    I just want to display from the console running this on linux. This is how i have the slot defined now

    void MainUi::doubleClicked( QModelIndex index )
    {
    QItemSelectionModel* selmodel = MyTableView->selectionModel();
    QModelIndex current = selmodel->currentIndex(); // the "current" item
    QModelIndexList selected = selmodel->selectedIndexes(); // list of "selected" items

    qDebug() << "current item = " << current.data();
    }

    this displays the value of the field i have clicked on. So what i need is to basically click on the first field in the column on a single row and not only display its value but also display the other 2 values in the columns next to it in the row, meaning the last 2 if this was a row of 3 columns. For now im just displaying using qDebug() in the slot.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get all column data from a single row with a QTableView and doubleclick

    Use QModelIndex::sibling() or QAbstractItemModel::index() to get other model indexes from the same row.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    azalea (5th March 2019)

  6. #5
    Join Date
    Jul 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: How to get all column data from a single row with a QTableView and doubleclick

    Thanks wysota

Similar Threads

  1. Replies: 1
    Last Post: 15th February 2012, 13:37
  2. QTableView crashes after doubleclick
    By nickla in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2011, 19:22
  3. Replies: 2
    Last Post: 5th September 2010, 14:06
  4. Replies: 1
    Last Post: 23rd November 2008, 14:11
  5. QTreeWidget Single Column Sort Disable
    By craigjameshamilton in forum Newbie
    Replies: 1
    Last Post: 21st April 2008, 08:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.