Qt4/Qt5 incompatible results of QTableWidget.selectedItems()?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Qt4/Qt5 incompatible results of QTableWidget.selectedItems()?

T.N.T.
Hello

When I have a QTableWidget with the following settings:


   tw.setColumnCount(2)
   tw.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)

and say I have selected the first two rows, then tw.selectedItems()
returns a list of 4 items.

Now in PyQt4 compiled with Qt4 the order is:

  [ c0_r0, c0_r1, c1_r0, c1_r1 ]

but compiled with Qt5:

  [ c0_r0, c1_r0, c0_r1, c1_r1 ]


Regards, T.
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Qt4/Qt5 incompatible results of QTableWidget.selectedItems()?

Andreas Pakulat
Hi,

Qt makes no guarantee on the order of returned items, it merely guarantee's that all items that are selected are returned in a list. There's no incompatibility, just a change in a behaviour that is not explicitly defined.

Andreas


On Tue, Jul 2, 2013 at 6:31 PM, T.N.T. <[hidden email]> wrote:
Hello

When I have a QTableWidget with the following settings:


  tw.setColumnCount(2)
  tw.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)

and say I have selected the first two rows, then tw.selectedItems() returns a list of 4 items.

Now in PyQt4 compiled with Qt4 the order is:

 [ c0_r0, c0_r1, c1_r0, c1_r1 ]

but compiled with Qt5:

 [ c0_r0, c1_r0, c0_r1, c1_r1 ]


Regards, T.
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Qt4/Qt5 incompatible results of QTableWidget.selectedItems()?

T.N.T.
On 02.07.2013 20:38, Andreas Pakulat wrote:
> Hi,
>
> Qt makes no guarantee on the order of returned items, it merely
> guarantee's that all items that are selected are returned in a list.
> There's no incompatibility, just a change in a behaviour that is not
> explicitly defined.


Thank you. So it was just no good idea to rely on the position in the
result list to access only the items in the left column. Okay. So I will
try my luck with QTableWidgetItem::column()...
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt