Results 1 to 3 of 3

Thread: Can'r find proper signal for QtableView QSqueryModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Can'r find proper signal for QtableView QSqueryModel

    I have QtablewView used with QSqlQueryModel.
    I want when a row is selected to make "remove" button enabled.When no selection is there the button to remain disabled.

    I figured out how to get signal when the selection has changed, but i need whether there is a selected row:

    Qt Code:
    1. QItemSelectionModel *sm = ui->tableView_partners->selectionModel();
    2. connect(sm, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
    3. this, SLOT(enableDeleteButton()));
    4.  
    5. void Partners::enableDeleteButton()
    6. {
    7.  
    8. if (ui->tableView_partners->selectionModel()->currentIndex().isValid() == true)
    9. {
    10. ui->pushButton_delete->setEnabled(true);
    11. }
    12.  
    13. else {
    14. ui->pushButton_delete->setEnabled(false);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Can'r find proper signal for QtableView QSqueryModel

    You can try connecting directly to your table view's selectionChanged signal.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can'r find proper signal for QtableView QSqueryModel

    QItemSelectionModel::selectedRows()?

    Cheers,
    _

Similar Threads

  1. selectionChanged() signal in qtableview
    By breakthecode in forum Newbie
    Replies: 7
    Last Post: 19th March 2015, 07:47
  2. Replies: 0
    Last Post: 30th May 2013, 21:59
  3. Replies: 1
    Last Post: 14th September 2010, 16:26
  4. clicked signal on qtableview does not exist?
    By jessn in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2010, 11:34
  5. QTableView Signal when nothing is selected
    By djjkotze in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2010, 15:00

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.