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. QTableView no selection signal

QTableView no selection signal

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

    I want to code a button that is disabled initially bt when someone selects a row in QTableView it is enabled, now coding it to enable is easy, but I also want it to disable automatically when there is no selection on QTableView. How can I do that?
    ~Thanks in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Looks like a job for QAbstractItemView::selectionChanged. Check if the selection is empty or not and enable your button based on that.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chronix
        wrote on last edited by
        #3

        how to do it? i don't have much idea bout subclassing.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No need for subclassing, just add a slot to whatever widget contains both your QPushButton and QTableView

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chronix
            wrote on last edited by
            #5

            @MainWindow::connect(ui->tableView, SIGNAL(ui->tableView->selectionChanged()), this, SLOT(disableEdit()));@

            something like this? I don't know what I'm typing, I'm a bit confused now.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Rather like that:
              @connect(ui->tableView, SIGNAL(ui->tableView->selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateEditState(QItemSelection,QItemSelection)));@

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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