Skip to content

Qt for Python

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

3.4k Topics 14.8k Posts
  • Failing to build PySide 6.9.2 in debug

    Solved
    5
    0 Votes
    5 Posts
    289 Views
    SGaistS
    Thank you ! :-)
  • Do I need to add qmldir for python objects exposed as singleton instances?

    Unsolved
    5
    0 Votes
    5 Posts
    167 Views
    M
    @JKSH I am trying to go through your answer step by step going from the simplest case and adding complexity. I am trying to use the decorators as you mentioned but I still cant get the qmllint or the language server to recognize my python types. The code works but in my qml file I will get a warning that the module can not be imported. @JKSH said in Do I need to add qmldir for python objects exposed as singleton instances?: In addition to QML instantiation, these decorators automatically generate the qmldir + *.qmltypes files. These files are read by qmllint and the QML Language Server (qmlls) to understand your Python types. I am not sure how adding a decorator to my class can generate these files so the language server can recognize the types. I feel like I am missing something here related to the qt tools provided for python but I cant see what. Going through the documentation I have tried to use pyside6-project build but nothing really happens even if I dont get any errors. I tried using pyside6-project qmllint and get the same warnings. My qml file and the .py file where the @QmlElement decorated class lives have been added to the pyproject.toml. Still not *.qmltypes are generated in this process. Information about these tools seems scarce so I am wondering if I am missing something.
  • Play multiple mp3 files with QMediaPlayer

    Solved
    3
    0 Votes
    3 Posts
    102 Views
    M
    I found a solution, it involves in connecting the signal "playingChanged" of QMediaPlayer to a function that plays the next track. self.player=QMediaPlayer() self.audioOutput = QAudioOutput() self.player.setAudioOutput(self.audioOutput) self.player.playingChanged.connect(self.play_next) def play_next(self): if self.player.playbackState()!=QMediaPlayer.PlaybackState.PlayingState: self.player.setSource(QUrl.fromLocalFile("next_track.mp3")) self.player.play()
  • I found an error on the PySide6 documentation website.

    Unsolved
    3
    1 Votes
    3 Posts
    84 Views
    F
    Yes, https://codereview.qt-project.org/c/pyside/pyside-setup/+/718662
  • Organization of QML tests

    Unsolved
    1
    0 Votes
    1 Posts
    40 Views
    No one has replied
  • 0 Votes
    2 Posts
    77 Views
    JKSHJ
    Hi, and welcome! @Sneako said in Qt Creator Designer "Line: 0: The Design Mode requires a valid Qt kit." with Kit installed and code buildable.: Yet designer complains about missing Qt a valid QtKit? Maybe the Qt Quick Designer only recognizes C++ kits. Does the warning disappear if you create a C++ project?
  • Suggestions for viewing 3D tool paths

    Unsolved qt for python
    2
    0 Votes
    2 Posts
    124 Views
    SGaistS
    Hi and welcome to devnet, Something like that likely exists but it's not part of the default set of Qt components. One thing you could do is explore KDE's extensive set of applications. There might be something there that you could leverage for your project.
  • How to optimize dlls when compiling using Nuitka for PySide6?

    Solved
    6
    0 Votes
    6 Posts
    381 Views
    SGaistS
    You might also want to check for the plugins you don't use. That said, it might be worth checking with the nuitka folks about supporting the exclusion of Qt modules rather than having to list all the dlls.
  • Qt Creator Design Mode for QML

    Unsolved
    6
    1 Votes
    6 Posts
    4k Views
    S
    I know this is an old post, but as I have searched the forums for this problem and could not find any solution i will post my findings here. As the code suggests it could not found a qt kit. In the kit menu, after a fresh install it has a qt kit and a python kit. Now the python kit does not contains the qt, and the qt kit does not contains the python env. The solution is easy, create a new kit that has both python and qt set. But simply creating a new one will not show the python option. In the default settings filter you need to tick python to visible, then in your new kit you can select both. After using this new kit you can use the designer.
  • 0 Votes
    4 Posts
    196 Views
    GrecKoG
    in QML it would have been: ScrollView { TextArea { TextField { anchors { right: parent.right bottom: parent.bottom margins: 16 } } } } As said by JonB in widgets you could override the parent resizeEvent or install an eventFilter handling QEvent::Resize on it and call your QTextField move function.
  • This topic is deleted!

    Solved
    3
    0 Votes
    3 Posts
    21 Views
  • Parent-child closing windows in pyside6

    Unsolved
    2
    0 Votes
    2 Posts
    335 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
    984 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
    832 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
    2k 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
    319 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
    222 Views
    No one has replied
  • Problem with exception handling in QOpenGLWidget

    Solved qt for python pyside
    5
    0 Votes
    5 Posts
    496 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!