1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- # pyqt reference
- # qt base development files
- $ doas apt-get install qtbase5-dev # qt 5 base development file
- $ doas apt-get install qt6-base-dev # qt 6 base development file
- qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
- qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
- This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
- Available platform plugins are: wayland-egl, vkkhrdisplay, vnc, eglfs, minimalegl, linuxfb, xcb, offscreen, wayland, minimal.
- Aborted
- $ doas apt-get install libxcb-cursor0
- # pyqtgraph
- https://pyqtgraph.readthedocs.io/en/latest/getting_started/how_to_use.html
- https://www.pythonguis.com/tutorials/plotting-pyqtgraph/
- from PyQt5.QtWidgets import QApplication, QWidget
- QApplication - the application handler
- QWidget - a basic empty GUI widget
- The main modules for Qt are QtWidgets, QtGui and QtCore.
- Next we create an instance of QApplication, passing in sys.argv, which is python
- list containing the command line arguments passed to the application.
- app = QApplication(sys.argv)
- If you won't be using command line arguments to control Qt you can pass in an
- empty list instead.
- app = QApplication([])
- Next we create an instance of a QWidget using the variable name window.
- window = QWidget()
- window.show()
- In Qt all top level widgets are windows - that is, they don't have a parent and
- are not nested within another widget or layout.
- Note: Widgets without a parent are invisible by default. So, after creating the
- window object, we must always call .show() to make it visible. You can remove
- the .show() and run the app, but you'll have no way to quit it!
- Window holds the user-interface of your application. Every application needs at
- least one (...but can have more). Application will (by default) exit when last
- window is closed.
- Finally, we call app.exec() to start up the event loop.
- The QApplication class - QApplication holds the Qt event loop - One QApplication
- instance required - Your application sits waiting in the event loop until an
- action is taken - There is only one event loop running at any time.
- The core Qt widgets are always imported from the QtWidgets namespace, as are the
- QMainWindow and QApplication classes.
- Note: When you subclass a Qt class you must always call the super __init__
- function to allow Qt to set up the object.
- QWidget documentation:
- https://doc.qt.io/qt-5/widget-classes.html#basic-widget-classes
- Sizing windows and widgets:
- In Qt sizes are defined using a QSize object. This accepts width and height
- parameters in that order. For example, the following will create a fixed size
- window of 400x300 pixels.
- window.setFixedSize(QtCore.QSize(400, 300))
- As well as .setFixedSize() you can also call .setMinimumSize() and
- .setMaximumSize() to set the minimum and maximum sizes respectively.
|