pyqtref.txt 2.9 KB

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