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. Is there a way to link or share a QTableWidgetItem between different QTableWidgets

Is there a way to link or share a QTableWidgetItem between different QTableWidgets

Scheduled Pinned Locked Moved General and Desktop
cellchangeditemchangedqtablewidgetqtablewidgetitetabs
2 Posts 2 Posters 1.8k 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.
  • I Offline
    I Offline
    Imnus
    wrote on last edited by Imnus
    #1

    Is there a way to link or share a QTableWidgetItem between different QTableWidgets

    Hi, in Qt I have a QMainWindow -> centralWidget (QWidget) -> QtabWidget -> then 10 Tabs (QWidgets) -> each with up to 26 QtableWidgets:

    Sample 1

    Sample 2

    Is there is a way to link some of the Items of each that are actually the same Item but it's repeated in each tableWidget, like for example the Player Name is the same per row in each tableWidget, so if the user edits the name in one, it should change it in the same row in every tableWidget.

    I could use the signal

    void QTableWidget::cellChanged(int row, int column)

    But then if the user had sorted on one of the Tabs, the Row and Column numbers won't match anymore on every Tab.

    I would also like that if I sort by column in one of the Tabs(tableWidget), the new arrangement of the rows should be the same in every Tab.

    Can anyone point me in the correct direction?

    By the way, whats the difference between

    void QTableWidget::cellChanged(int row, int column)

    and

    void QTableWidget::itemChanged(QTableWidgetItem

    Because I've been able to use QTableWidget::cellChanged correctly but I've no idea how to use QTableWidget::itemChanged, how do you use it, an example please.

    Thanks a lot for your time.

    mrjjM 1 Reply Last reply
    0
    • I Imnus

      Is there a way to link or share a QTableWidgetItem between different QTableWidgets

      Hi, in Qt I have a QMainWindow -> centralWidget (QWidget) -> QtabWidget -> then 10 Tabs (QWidgets) -> each with up to 26 QtableWidgets:

      Sample 1

      Sample 2

      Is there is a way to link some of the Items of each that are actually the same Item but it's repeated in each tableWidget, like for example the Player Name is the same per row in each tableWidget, so if the user edits the name in one, it should change it in the same row in every tableWidget.

      I could use the signal

      void QTableWidget::cellChanged(int row, int column)

      But then if the user had sorted on one of the Tabs, the Row and Column numbers won't match anymore on every Tab.

      I would also like that if I sort by column in one of the Tabs(tableWidget), the new arrangement of the rows should be the same in every Tab.

      Can anyone point me in the correct direction?

      By the way, whats the difference between

      void QTableWidget::cellChanged(int row, int column)

      and

      void QTableWidget::itemChanged(QTableWidgetItem

      Because I've been able to use QTableWidget::cellChanged correctly but I've no idea how to use QTableWidget::itemChanged, how do you use it, an example please.

      Thanks a lot for your time.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      The QTableWidget is item-based. meaning you insert the data into the widget and it takes control of it. (owns it)
      So sharing between QTableWidgets is not really working.

      However, the QTableView is a view-model object.
      Here your data lives in a object (the model) that the QTableView asks for data.

      It is possible to share this model between QTableViews and if you
      update any field, it would be the same for all as "playername" would only exists once.

      So if you have not,please read about QTableView and Qt's model/view framework.

      If only player name is shared, then using a model might be a bit overkill. Still super flexible.

      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