Skip to content

Qt for Python

For discussion and questions about Qt for Python (PySide & Shiboken)

3.3k Topics 14.8k Posts
  • Problem with exception handling in QOpenGLWidget

    Solved qt for python pyside
    5
    0 Votes
    5 Posts
    62 Views
    A
    Yes, sorry. I've got carried away. I do understand your point. And I agree that it's best to avoid situations where there are unhandled exceptions in Python code called from Qt. Because it may prevent some important code on the C++ side from executing. I'm just confused by the difference in this case, as the behavior changes between versions and when overriding methods in other classes. The thing is, in my short experience with PySide6, I somehow assumed the wrapper handled exception forwarding back to Python automatically. Apparently, that is not the case and I've been lucky until recently. I'll take your suggestion. @JonB said in Problem with exception handling in QOpenGLWidget: There may be better approached (I am not a Python expert), but to help debugging you might write everything like this: try: <your code> except Exception as e: unhandled_exception(e) <suitable continuation> def unhandled_exception(e): print (e) The only difference is that instead of print, I'll use logging.error to get an exception traceback. Thank you for your time!
  • Pre-allocating a space to insert my specialized widget

    Unsolved
    2
    0 Votes
    2 Posts
    59 Views
    JonBJ
    @BegBlev So that I understand --- and I am more C++ than Python --- are you using Designer's Promote to ... from the widget's context menu, e.g. as per https://www.pythonguis.com/tutorials/embed-pyqtgraph-custom-widgets-qt-app/ ?
  • Resources text file unable to be opened in Windows, but works fine in Linux

    Solved
    15
    1 Votes
    15 Posts
    534 Views
    T
    For anyone else who is having issues similar to mine: I have confirmed that by running pyside6-rcc with --compress-algo zlib allows for the creation of a resources file that works cross-platform, at the cost of a larger resources file size. So, if you need cross-platform compatibility for your resources files that are generated on Linux but pulled on other platforms, be sure to use zlib as the compression algorithm, rather than the default of zstd (which isn't even available on Windows). I'm going to mark this as solved, but will be going through the bug report I mentioned above to hopefully get some documentation written about this inconsistency.
  • 0 Votes
    3 Posts
    282 Views
    R
    Thank you very much for your reply. I have used 3.10. It works when I upgrade to 3.12.
  • 0 Votes
    7 Posts
    916 Views
    B
    Update: Configuration still: Python version: 3.9.6 (default, May 7 2023, 23:32:45) PySide6 version: 6.7.0 Results: Inheritance with QRasterWindow and QWidget is failing. Inheritance with QDate is succeeding. Further work: try with a more recent Python version and a more recent PySide version.
  • PySide6.QtGraphs.QSurfaceDataProxy.resetArrayNp called with wrong argument types:

    Solved
    7
    0 Votes
    7 Posts
    217 Views
    SGaistS
    @G4IXT Hi, As an alternative you can very well install PySide6 in your conda environment using pip. That way you can use conda to manage your environments.
  • macOS Trackpad Gestures - Simultaneous Pinch & Pan?

    Unsolved
    2
    0 Votes
    2 Posts
    163 Views
    jsulmJ
    @mjiggidyj said in macOS Trackpad Gestures - Simulatneous Pinch & Pan?: any positional info I get from the QNativeGestureEvent during pinch (from pos(), etc) is not updated What about https://doc.qt.io/qt-6/qnativegestureevent.html#delta ?
  • [PySide6] Unable to listen to DBUS ScreenSaver ActiveChanged Signal

    Unsolved pyside
    1
    0 Votes
    1 Posts
    86 Views
    No one has replied
  • ModernGL with QOpenGLWidget isn't rendering

    Solved qt for python
    7
    0 Votes
    7 Posts
    2k Views
    H
    Hi, For those looking for a functional answer: import sys import moderngl as GL import numpy from PyQt6.QtWidgets import QApplication from PyQt6.QtOpenGLWidgets import QOpenGLWidget class Main(QOpenGLWidget): def __init__(self, parent=None): super().__init__(parent) def initializeGL(self): # Set up the OpenGL context using moderngl self.ctx = GL.create_context() self.ctx.clear(0, 0, 0) # Define shaders with error checking vertex_shader_code = ''' #version 330 core in vec3 in_vert; void main() { gl_Position = vec4(in_vert, 1.0); } ''' fragment_shader_code = ''' #version 330 core out vec4 fragColor; uniform vec4 color; void main() { fragColor = color; } ''' # Compile shaders and program self.program = self.ctx.program( vertex_shader=vertex_shader_code, fragment_shader=fragment_shader_code ) # Check for any shader compilation issues if not self.program: print("Shader program failed to compile.") return # Define triangle vertices (in normalized device coordinates) self.vertices = numpy.array([ 0.0, 0.5, 0.0, # Top vertex -0.5, -0.5, 0.0, # Bottom-left vertex 0.5, -0.5, 0.0 # Bottom-right vertex ], dtype='f4') # Create the buffer for the vertices self.vbo = self.ctx.buffer(self.vertices) # Create vertex array object (VAO) self.vao = self.ctx.simple_vertex_array(self.program, self.vbo, 'in_vert') # Set the uniform color (Red in this case) self.program['color'].value = (1.0, 0.0, 0.0, 1.0) # Red # EDITED: 1.0, 1.0, 1.0 is white. def resizeGL(self, w, h): # EDITED: Detect framebuffer again after resize. # To be fair: Claude AI gave me this solution. fbo = self.ctx.detect_framebuffer() fbo.use() self.ctx.viewport = (0, 0, w, h) def paintGL(self): # Clear the screen self.ctx.clear(0.0, 0.0, 0.0) # Draw the triangle self.vao.render() if __name__ == '__main__': app = QApplication([]) win = Main() win.resize(800, 600) win.show() sys.exit(app.exec())
  • Did pyside6 ever support macOS 10.13?

    Unsolved
    2
    0 Votes
    2 Posts
    133 Views
    I
    It doesn't appear so, no. The minimal version ever supported by Qt 6 (as seen in the 6.0 documentation archives) is 10.14 - https://doc.qt.io/archives/qt-6.0/supported-platforms.html.
  • Qt Designer - unable to replicate qtdesigner-manual form

    Unsolved
    12
    0 Votes
    12 Posts
    883 Views
    JonBJ
    @ReyCBXZRX I don't always follow the logic or English of what you write, but never mind :) A QSpinBox has a pair of "scroll arrows" at the right but it is not a "scrollbar". These are for inc/decrementing the number value and have nothing to do with scrolling or sizing. A QLineEdit is for entering text (rather than number), is single line and has no scrollbars. A QTextEdit or QPlainTextEdit is for multiline text, can be resized vertically and can have scrollbars. There are two ways of adding a layout to a widget in Designer. Each widget can have a layout set by right-clicking on it and selecting Layout > menu item. However for unknown/inexplicable reason this is only enabled when the parent widget has had at least one child widget placed on it, you cannot do it before you add any child widget, which is rather odd. Alternatively there are explicit layout items available at the top of the all the items you can drag from the left-hand side toolbar, these can be dragged and placed anytime. I have never understood/investigated whether there is any difference in result between these two methods. With layouts there should be no "overlapping", it is their job to prevent this. One tip: If you look at the Object Explorer --- the pane at the right which shows all your placed widgets in their hierarchy --- you will see a "red no entry" symbol on any widgets you have created which do not have a layout but should have. If you see that you know you should be adding a layout there.
  • How can I call the const method variant on a Qt object from Python?

    Unsolved qt for python pyside
    3
    0 Votes
    3 Posts
    185 Views
    K
    Thanks for clarifying. I suspected this would be the case but I thought it was worth asking the question.
  • Python 3.14 timeline

    Unsolved
    4
    0 Votes
    4 Posts
    275 Views
    F
    Qt for Python 6.10.1 /6.11 will support Python 3.14
  • QGraphicsAnchorLayout quirks and UI bugs.

    Unsolved pyside2 qt for python
    1
    0 Votes
    1 Posts
    81 Views
    No one has replied
  • QtQuick.VectorImage in PySide6

    Unsolved
    8
    0 Votes
    8 Posts
    758 Views
    SGaistS
    @usymbiote you can check the bug report system. If there's nothing related yet, please open a new ticket.
  • looking for a code editor widget for Qt for Python

    Unsolved
    9
    1 Votes
    9 Posts
    2k Views
    RokeJulianLockhartR
    @nutrx, work is being made toward this at invent.kde.org/frameworks/ktexteditor/-/issues/24 and its superordinate issue.
  • No suitable kits found

    Unsolved
    2
    0 Votes
    2 Posts
    174 Views
    jsulmJ
    @Milosz said in No suitable kits found: How to fix the problem? By manually adding your Python installation in Python/Interpreter in QtCreator settings.
  • PySide vs PyQt ui file load.

    Unsolved pyside
    8
    0 Votes
    8 Posts
    932 Views
    JonBJ
    @swoiwode Yes, you have made the right changes! Note how you changed from PyQt6.uic.loadUi(ui_file, self), which loaded into self and gave you self.label etc. over to self.ui = PySide6.QtUiTools.QUiLoader().load(ui_file), which returned into a newly created self.ui (or whatever you choose to call it) and hence gave you self.ui.label etc. It's just a different way of doing things, and PySide just does not offer that parameter or loading into self. Looking around at what examples there are on the web I found that actually even in PyQt more people had worked from self.ui = PyQt6.uic.loadUi(ui_file) which is also available and similar to the PySide way than that "non-standard" PyQt6.uic.loadUi(ui_file, self) which the code you inherited had chosen to use. Honestly you came across one of the few difference between PyQt and PySide right from the outset in the small script you were working on. 99% of the time you should find that same code simply works from PyQt to PySide.
  • Pyside on Boot2Qt in RaspberryPi5

    Unsolved
    2
    0 Votes
    2 Posts
    154 Views
    jsulmJ
    @Pritha-Suresh Since you're accessing the device via ssh you need to forward X11 if you want to run a GUI application this way, see -X ssh parameter, Also the error you get hints that you did not install X11 on the device.
  • Font clipping of custom Italic fonts

    Unsolved
    3
    0 Votes
    3 Posts
    258 Views
    M
    This was with PySide6 6.9.2, I also tried with 6.10.0 The OS is Windows 10 22H2

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.