[PyQt] problems to use QTableView

Sibylle Koczian nulla.epistola at web.de
Wed May 18 21:10:15 BST 2016


Am 18.05.2016 um 21:32 schrieb Daniel Krause:
> Hello,
>
> I have some problems to understand how to use QTableView.
>
> When I run this code
>
>     if __name__ == '__main__':
>         import pandas
>         from PyQt5 import QtCore
>         from PyQt5.QtWidgets import QTableView
>         from PyQt5.QtGui import QGuiApplication
>         import sys
>
>         print('initialize app')
>         application = QGuiApplication(sys.argv)
>         print('initialize view')
>         view = QTableView()
>         print(view)
>         print('do something else')
>
>
> the execution of the script stops before
>
>         print(view)
>         print('do something else')
>
>
> What am I missing?
>

I think you need

view.show()
application.exec_()

after creating the view. Moreover you should use QApplication, not 
QGuiApplication. From the Documentation for QGuiApplication:

"""
For non-GUI Qt applications, use QCoreApplication instead, as it does 
not depend on the Qt GUI module. For QWidget based Qt applications, use 
QApplication instead, as it provides some functionality needed for 
creating QWidget instances.
"""

HTH
Sibylle









More information about the PyQt mailing list