Results 1 to 3 of 3

Thread: How to know which qtableview is currently displayed

  1. #1
    Join Date
    Jun 2012
    Posts
    33
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How to know which qtableview is currently displayed

    Hello everyone. I am just another newbie trying to develop some code on QT. Up until now I have been able to find most of the answers to my questions online but now I have a question that needs your expert advice.

    I have a window that connects to a database and displays the contents in Qtableview. The twist here is that based on the value of a field the records are filtered into 5 different tableviews each in its own tabbed page. A view of the window is shown below.

    qtreport1.jpg

    Now I have 1 problem and 1 concern.

    The problem is that the edit button only works for the first tableview because I have it hardcoded in the Find code as shown.
    int pIndex = ui->tableView->model()->index(ui->tableView->currentIndex().row(),0).data().toInt();

    How can I make the code understand that I moved to a new tableview and the edit button will get the index of that view?

    The concern that I have is that for each tableview I create a new model and filter the model based on each value of the field I want. Namely the weight as shown in the image. Is that the right way of doing it or am I complicating stuff?

    Thanking you in advance for all your help,

    Pericles

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to know which qtableview is currently displayed

    You are using QTabWidget. So use QTabWidget::currentIndex method to detect selected tab.

  3. #3
    Join Date
    Jun 2012
    Posts
    33
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to know which qtableview is currently displayed

    Thank you for your prompt reply. This was exactly what I was looking for.

    Pericles

Similar Threads

  1. Change QTableView's index number displayed
    By rex in forum Qt Programming
    Replies: 0
    Last Post: 6th April 2011, 15:30
  2. Digram not displayed.
    By mikl in forum Qwt
    Replies: 1
    Last Post: 11th March 2011, 17:07
  3. 's' is displayed instead of 'σ'
    By babygal in forum Newbie
    Replies: 7
    Last Post: 21st October 2010, 21:48
  4. No checkboxes are displayed in a QTableView
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2010, 17:28
  5. image not displayed ...
    By sh123 in forum Qt Tools
    Replies: 4
    Last Post: 15th December 2008, 13:07

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.