Skip to content

Fix return type of QTableWidget.cellWidget#198

Merged
altendky merged 3 commits intopython-qt-tools:masterfrom
mkrieger1:master
Nov 22, 2022
Merged

Fix return type of QTableWidget.cellWidget#198
altendky merged 3 commits intopython-qt-tools:masterfrom
mkrieger1:master

Conversation

@mkrieger1
Copy link
Copy Markdown
Contributor

cellWidget returns a QWidget if it exists, or None if it doesn't exist.

Confirmed by this short script:

from PyQt5 import QtCore, QtWidgets

print(f'Qt {QtCore.QT_VERSION_STR}')
print(f'PyQt {QtCore.PYQT_VERSION_STR}')

app = QtWidgets.QApplication(['foo'])
table = QtWidgets.QTableWidget(1, 1)

# empty cell inside table
print(table.cellWidget(0, 0))

# filled cell inside table
table.setCellWidget(0, 0, QtWidgets.QWidget())
print(table.cellWidget(0, 0))

# cell outside table
print(table.cellWidget(99, 99))

Output:

Qt 5.15.2
PyQt 5.15.6
None
<PyQt5.QtWidgets.QWidget object at 0x7fa13208bca0>
None

@altendky
Copy link
Copy Markdown
Collaborator

Looking at fixing main CI in #199.

@altendky altendky closed this Nov 22, 2022
@altendky altendky reopened this Nov 22, 2022
@altendky
Copy link
Copy Markdown
Collaborator

I hope you don't mind me jumping in and pushing a few details here. Just saves the back and forth which can be long when I know I haven't been particularly responsive.

But, thanks for the correction!

@altendky altendky merged commit bfac825 into python-qt-tools:master Nov 22, 2022
@mkrieger1
Copy link
Copy Markdown
Contributor Author

Sure, thanks!

@bluebird75
Copy link
Copy Markdown
Collaborator

If you can add a test for this, that would be even better. The spirit of the tests is to run very small code snippets and make sure they typecheck correctly.

@mkrieger1
Copy link
Copy Markdown
Contributor Author

I will look into it.

mkrieger1 added a commit to mkrieger1/PyQt5-stubs that referenced this pull request Dec 16, 2022
altendky added a commit that referenced this pull request Dec 18, 2022
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.

3 participants