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. Any way to know the column clicked in a row QTreeWidget?
Forum Updated to NodeBB v4.3 + New Features

Any way to know the column clicked in a row QTreeWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 969 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.
  • RipleyR Offline
    RipleyR Offline
    Ripley
    wrote on last edited by
    #1

    Welcome everybody, searching help for this issue.

    Once built a QTreeWidget and ready to select several items to clicking with CTRL or SHIFT . Just want to know the way of take the specific column item in selected row by the click after changed its value, the main reason of this is at the moment of change the value of the column the other elements selected change their value too in the corresponding column like an excel table, It's hard to begin for something.

    My code are here:

    void StudyHours::on_mainTreeWidget_itemChanged(QTreeWidgetItem *item, int column)
    {
        QList<QTreeWidgetItem *> itemsListSelected;
        itemsListSelected = ui->mainTreeWidget->selectedItems();
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
        foreach (QTreeWidgetItem *item, itemsListSelected) {
        }
        QApplication::restoreOverrideCursor();
    }
    

    In resume:

    • Just know the value of column selected after changed
    • Change every values at the same column in the rows that had been.

    Thanks boys.

    JonBJ 1 Reply Last reply
    0
    • RipleyR Ripley

      Welcome everybody, searching help for this issue.

      Once built a QTreeWidget and ready to select several items to clicking with CTRL or SHIFT . Just want to know the way of take the specific column item in selected row by the click after changed its value, the main reason of this is at the moment of change the value of the column the other elements selected change their value too in the corresponding column like an excel table, It's hard to begin for something.

      My code are here:

      void StudyHours::on_mainTreeWidget_itemChanged(QTreeWidgetItem *item, int column)
      {
          QList<QTreeWidgetItem *> itemsListSelected;
          itemsListSelected = ui->mainTreeWidget->selectedItems();
          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
          foreach (QTreeWidgetItem *item, itemsListSelected) {
          }
          QApplication::restoreOverrideCursor();
      }
      

      In resume:

      • Just know the value of column selected after changed
      • Change every values at the same column in the rows that had been.

      Thanks boys.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Ripley
      I don't understand much about your question, or what the relevance of "after changed its value" is, but in answer to your title:

      Any way to know the column clicked in a row QTreeWidget?

      there is signal void QTreeWidget::itemClicked(QTreeWidgetItem *item, int column), https://doc.qt.io/qt-5/qtreewidget.html#itemClicked.

      1 Reply Last reply
      2
      • RipleyR Offline
        RipleyR Offline
        Ripley
        wrote on last edited by
        #3

        @JonB Thanks bro.

        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