python-qt-tools / PyQt5-stubs

Stubs for PyQt5
GNU General Public License v3.0
68 stars 31 forks source link

Fix annotations for QTableWidget #151 #189

Closed TilmanK closed 2 years ago

TilmanK commented 2 years ago

Ok, so here's the PR. I've tested every method and indeed every one of them either returns a None when called with invalid values or accepts None as argument, which is convenient regarding use-cases like this:

row = table_widget.row(table_widget.itemAt(QPoint(42, 42)))

I'll update the PR later today with fixes for QListWidget and QTreeWidget as well.

TilmanK commented 2 years ago

@bluebird75 Go ahead, it's complete. I've confirmed in simple examples that the changes are correct - you can really build complex widget structures just by passing None around ;)

bluebird75 commented 2 years ago

Nice.

Unrelated but I want to get started on PyQt6-stubs. Can you rejoin the thread on #69 ? I see that you have a repo with some code for it.

mkrieger1 commented 2 years ago

I believe QTableWidget.cellWidget should return Optional[QWidget], not List[QWidget]. Can someone confirm that List[QWidget] was a mistake, or am I wrong?

(I already wrote an inline comment here, but I'm not sure if this triggered a notification for anybody involved.)

altendky commented 2 years ago

https://doc.qt.io/qt-5/qtablewidget.html#cellWidget

[QWidget](https://doc.qt.io/qt-5/qwidget.html#QWidget) *QTableWidget::cellWidget(int row, int column) const

Looks like it shouldn't be a List, yeah. It doesn't clearly state that the pointer can be NULL, but I'd guess it can be. Maybe you could explore at runtime to double check? And provide a pr?

mkrieger1 commented 2 years ago

Created #198.