Skip to content

Qt for Python

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

3.3k Topics 14.8k Posts
  • Parent-child closing windows in pyside6

    Unsolved
    2
    0 Votes
    2 Posts
    38 Views
    SGaistS
    Hi, From the top of my head: opening widgets upon opening widgets within a constructor is usually bad design. Even more when the window variable is local to the function. I would recommend properly building your widgets and only after that start your business logic and have proper functions that will create and further show these widgets.
  • OS-independent colour scheme with PySide6

    Solved
    7
    0 Votes
    7 Posts
    235 Views
    H
    @SimonSchroeder said in OS-independent colour scheme with PySide6: @SGaist said in OS-independent colour scheme with PySide6: I am wondering whether the red should be a bit darker in the the dark mode. This could certainly help. In the same way, it could help to make the white lines a light gray instead. I'd love to do that, but there lies my "Qt rookie" problem again, I see many ways but don't know best practice. I have presently used roles everywhere, and the lines have the "text" role which makes them white in Win 11 dark mode. When a light/dark switch happens while the app is open, QT6 does everything for me, except the green background of the "Weight" input field, which signifies a valid SymPy expression. I made that with style sheets, so it updates only when the field redraws. Right after a dark-to-light switch the field will still be a darker green with white text. Would the proper way be to do the gray line with style sheets, detect a mode change, and redraw, or can I add roles that then update automatically at light/dark switch? Or should I work with two palettes?
  • close bottom window of QMainWindow

    Unsolved
    7
    0 Votes
    7 Posts
    332 Views
    JonBJ
    @C.J.-Mejias Given that you say: self.setWindowFlags(self.windowFlags() & ~Qt.WindowMinMaxButtonsHint) # does not work self.setWindowFlags( flags = Qt.Window | Qt.WindowCloseButtonHint) # does work I would check before executing the first statement what self.windowFlags() had in it --- did it include Qt.Window and Qt.WindowCloseButtonHint to start with? And for that matter also what it returns after that statement, so that we know what the flags have actually been changed to. All it should be doing is switching off whatever is in Qt.WindowMinMaxButtonsHint, which should not be anything to do with Qt.Window or Qt.WindowCloseButtonHint. You have not yet discovered whether this change in behaviour is to do with Qt, PySide or Python.
  • 0 Votes
    11 Posts
    1k Views
    B
    @Ville-Voutilainen thanks for the information. The order of declaration shall be the same in C++ and Ada. If the order change on C++ side, you must regenerate all. I guess this also implies to get the exact source code that have been used to build Qt library which has been released. Generating Ada code from headers needs to set judiciously all defines that may differ from an OS to another. I don't know how to cope with that. Binding of multi-inheritance classes will be an issue too. I would like to hope that it succeeds, but I haven't seen any new elements to that end.
  • Qt3d - camera transforms not working

    Unsolved
    2
    0 Votes
    2 Posts
    202 Views
    SGaistS
    Hi, There might be chances but you need to provide a minimal reproducer script for people to get started to debug things.
  • ModernGL with QOpenGLWidget isn't rendering

    Solved qt for python
    8
    0 Votes
    8 Posts
    2k Views
    W
    dont use self.ctx.clear in paintGL because its can make your shader into black fill, so you just write ctx.clear in initializeGL like this def initializeGL(self): self.ctx = moderngl.create_context() self.ctx.clear(0,0,0,0)
  • Reliable position to pop context menus for tray icon on left click with Wayland

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    J
    Use KStatusNotifierItem with setIsMenu(True) will give the desired effect. KStatusNotifierItem's python bindings can be installed through your system package manager (so can't be used in a venv so far).
  • 0 Votes
    1 Posts
    123 Views
    No one has replied
  • Problem with exception handling in QOpenGLWidget

    Solved qt for python pyside
    5
    0 Votes
    5 Posts
    304 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
    172 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
    1k 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
    415 Views
    R
    Thank you very much for your reply. I have used 3.10. It works when I upgrade to 3.12.
  • PySide6.QtGraphs.QSurfaceDataProxy.resetArrayNp called with wrong argument types:

    Solved
    7
    0 Votes
    7 Posts
    391 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
    376 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
    195 Views
    No one has replied
  • Did pyside6 ever support macOS 10.13?

    Unsolved
    2
    0 Votes
    2 Posts
    289 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
    1k 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
    352 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
    394 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
    154 Views
    No one has replied