Skip to content

Fix annotations for QTableWidget #151#189

Merged
bluebird75 merged 4 commits intopython-qt-tools:masterfrom
TilmanK:master
Jan 6, 2022
Merged

Fix annotations for QTableWidget #151#189
bluebird75 merged 4 commits intopython-qt-tools:masterfrom
TilmanK:master

Conversation

@TilmanK
Copy link
Copy Markdown
Contributor

@TilmanK TilmanK commented Jan 4, 2022

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
Copy link
Copy Markdown
Contributor Author

TilmanK commented Jan 5, 2022

@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
Copy link
Copy Markdown
Collaborator

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.

@bluebird75 bluebird75 merged commit 52ed479 into python-qt-tools:master Jan 6, 2022
@mkrieger1
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Collaborator

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
Copy link
Copy Markdown
Contributor

Created #198.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants