Skip to content

Qt for Python

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

3.3k Topics 14.4k Posts
  • Centered text in QGraphicsView

    Unsolved about 7 hours ago
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • 0 Votes
    11 Posts
    180 Views
    @memyselfandi Important is to not to mix different Qt versions
  • How to acquire the frame colour?

    Unsolved 2 days ago
    0 Votes
    1 Posts
    30 Views
    No one has replied
  • Pyqt5 : finding the selection in a qTextEdit

    Unsolved 2 days ago
    0 Votes
    2 Posts
    35 Views
    Hi and welcome to devnet, Which position do you mean ? In widget coordinates ? The number of chars from the start of the text ?
  • QGraphicsLayout not properly resizing to change of content

    Unsolved 24 Jun 2020, 08:27
    0 Votes
    5 Posts
    750 Views
    14/5000 So in the end, in what way was it solved?
  • Unable to run a Pyside6 application in QtCreator

    Solved 4 Jan 2023, 21:13
    0 Votes
    7 Posts
    1k Views
    I know this post is old, but in my case when I got this error, I was missing the tomlkit module in my python installation.
  • Why does PySide6 need glibc 2.39 since 6.8.1 on aarch64?

    Solved 4 Mar 2025, 10:45
    0 Votes
    4 Posts
    220 Views
    After doing some digging I found this thread. My Python project on Raspberry Pi OS requires PySide6==6.8.3 or later which depends on glibc 2.39 but RPiOS only provides 2.36. I tried building from source and containerising it with chroot but neither produced the proper result. I'm going try switching to Ubuntu Server 24.04 for Raspberry Pi and hope for the best seeing as it will have the proper glibc version. If I don't report back within the week assume that it worked.
  • Main window always opens on 'incorrect' monitor

    Solved 9 days ago
    0 Votes
    4 Posts
    90 Views
    Hi All, first things first, I am stuck on python 3.7.3. I tried upgrading to the latest supported version of pyside6 which seems to be 6.5.3. This seems to have fixed my issue. I did make a python version of @CassD script and using pyside 6.2.4, I get the following output manufacturer : model : Screen Name : LF24T450F Screen Size : PySide6.QtCore.QSize(1920, 1080) While using pyside 6.5.3, I get the following manufacturer : Samsung Electric Company model : LF24T450F Screen Name : LF24T450F (1) Screen Size : PySide6.QtCore.QSize(1920, 1080) manufacturer : Samsung Electric Company model : LF24T450F Screen Name : LF24T450F (2) Screen Size : PySide6.QtCore.QSize(1920, 1080) So it seems version 6.2.4 does have some issues detecting screens. In any case, my issue is now resolved, thanks.
  • Get XY Coordinates of QTextCursor

    Solved 8 days ago
    0 Votes
    3 Posts
    82 Views
    @IgKh Thanks so much for your direction. That was exactly what I needed! Here is the code I used: #####determine the cursor position to scroll the scrollArea as needed #get the blockBoundingRect of the block that holds the QTextCursor blockRect = self.doc.documentLayout().blockBoundingRect(self.cur.block()) #get the QTextLine that holds the QTextCursor cursorLine = self.cur.block().layout().lineForTextPosition(self.cur.positionInBlock()) #get the QTextLine's naturalTextRect so we can get the Y center of the QTextCursor self.cursorLineRect = cursorLine.naturalTextRect() #translate the cursorLineRect to the blockRect self.cursorLineRect.translate(blockRect.x(),blockRect.y()) #get the approximate X position of the cursor cursorToX = cursorLine.cursorToX(self.cur.positionInBlock(), QTextLine.Edge.Leading) #create a QPointF from the cursorToX posistion and the center of the CursorLineRect self.cursorPoint=QPointF(float(cursorToX[0])+blockRect.x(),self.cursorLineRect.center().y()) #instruct the QScrollArea to keep the QPointF visible with 100px padding self.main_window.scrollArea.ensureVisible(self.cursorPoint.x(), self.cursorPoint.y(),100,100) Then to confirm my computation was correct I painted self.cursorPoint using painter.drawPoint(self.cursorPoint) . You can see the little red dot following the text cursor in the screenshot below. Your guidance solved my problem 100% [image: 76f8252d-e31d-406b-8d53-f90af5c226ad.JPG]
  • Is building for iOS supported?

    Unsolved 7 Apr 2025, 05:18
    0 Votes
    7 Posts
    200 Views
    Ah ok, thanks for the ticket. Watched and voted. So it looks like it is a question of priority and bandwidth. I have not played with pyside6-deploy for the other platforms yet. I suppose that would be the place to start before looking for the problems arising from applying the same technique to iOS. Is there a published development plan where this falls for the Qt Company's internal developer resources?
  • Generating PY from QRC Everytime a Resource file changes

    Unsolved 27 Nov 2020, 17:28
    0 Votes
    4 Posts
    349 Views
    I made a batch script that I run every time I detect that the .qrc (or .ui) files have changed. It's all automated before launching the application.
  • PySide6 QLineSeries doesn't plot correctly

    Unsolved 28 days ago
    0 Votes
    3 Posts
    98 Views
    @JonB said in PySide6 QLineSeries doesn't plot correctly: this should not be a PySide6/Python issue Yes, https://bugreports.qt.io/browse/PYSIDE-3083 For it seems not so robust, I tries PythonQwt, but it is not complete, e.g. QwtArraySeriesData is not ported for python. Now I'm using matplotlib with qtagg backend, it works fine. It's said that QtGraphs is going to replace QtCharts, but the API in C++ is not complete so far, I'll follow it. Thanks
  • Pyside6 on embedded linux

    Unsolved 14 Oct 2024, 15:11
    0 Votes
    2 Posts
    244 Views
    Hello, I’m running into the exact same problem on a Raspberry Pi with the latest Debian and a fresh PySide6 6.9.0 install—there simply isn’t any eglfs_kms support. If I switch to the eglfs_linuxfb backend, everything works perfectly, so I suspect the KMS integration might be deliberately omitted in the pip-distributed Qt for PySide6. For now I’m sticking with linuxfb, but I’d like to understand what limitations this entails compared to KMS (I don’t need multi-screen setups, 3D acceleration or video playback). I even managed to build a custom Qt from source with KMS support, but haven’t been able to persuade PySide6 to use that build instead of its bundled Qt. I also tried building PySide6 from source with qt_path pointed at my custom Qt, but that didn’t work either. Any insights into why eglfs_kms isn’t included, or how to make PySide6 pick up my KMS-enabled Qt, would be greatly appreciated.
  • FocusOutEvent get stuck in a loop

    Unsolved 22 days ago
    0 Votes
    7 Posts
    502 Views
    I've been digging through this some more and what appears to be happening is when I press tab to leave line_edit1 it goes to my focusOutEvent of CustomLineEdit1 and sets the focus back to line_edit1 but it is like the focus has also transferred over to line_edit2 so when the super().setfocus of line_edit1 happens then line_edit2 sees that and fires off it's focusOutEvent and this keeps going back and forth since they each see the focus leaving their respective line edits. If I remove the super().setfocus from the else of line_edit2 things work because there is nothing telling it to take the focus back away from line_edit1. The problem with this is that after I do go on to line_edit2 and tab out of it to go to line_edit3, with out the super().setfocus in the else the focus does not return to line_edit2 like I need it to. The event.accept() have had no effect. Unless there is something else going on here it seems like the focus should never make it to line_edit2 if I'm intercepting the focusOutEvent of line_edit1 and changing it.
  • Defer Resize Event due to expensive resize method.

    Unsolved 2 Apr 2025, 13:50
    0 Votes
    5 Posts
    189 Views
    @SimonSchroeder I think I'm already doing what you're suggesting. I've implemented a custom resizeEvent(...) that calls timer.start() on a single shot timer every time a ResizeEvent is recieved. This also resets the timer if an event is received shortly after another. And then I perform the actual resize of the widget when the timer times out. ChatGPT Suggested using this: import sys from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel from PyQt6.QtCore import QTimer, QAbstractNativeEventFilter from PyQt6.QtGui import QGuiApplication class NativeResizeFilter(QAbstractNativeEventFilter): """Listens for native window events to detect when resizing stops.""" def __init__(self, callback): super().__init__() self.callback = callback # Function to call when resize stops def nativeEventFilter(self, eventType, message): from ctypes import windll if eventType == "windows_generic_MSG": msg = int.from_bytes(message[:8], byteorder=sys.byteorder) WM_EXITSIZEMOVE = 0x0232 # Windows event when resizing stops if msg == WM_EXITSIZEMOVE: self.callback() return False, 0 It seems (!) to be potentially possible to do the deferred scaling using events on Windows. I've also looked into dealing with NativeEvents on MacOS and Linux however, it seems to be rather tedious. So as for now, I've opted to go with the timer and maybe do the fancy resizing if I have the time to spare. AliSot2000
  • This topic is deleted!

    Unsolved 25 days ago
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • QMediaPlayer with reduced video resolution

    Moved Unsolved 30 days ago
    0 Votes
    4 Posts
    128 Views
    So the backend uses ffmpeg however I don't think that you currently can delegate the resizing to it. You could do it in a sink though but I am unsure about the performance of it.
  • Hiding viewer panel vs window maximization

    Moved Unsolved 10 Apr 2025, 08:55
    0 Votes
    2 Posts
    83 Views
    When the state of self.was_maximized changed, the second if in adapt_viewer_panel is not working as expected. Adding self.was_maximized = not hide_viewer_panel to the else statement worked for me: def adapt_viewer_panel(self): if hide_viewer_panel: self.setFixedWidth(200) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) self.viewer_panel.hide() else: self.setMinimumWidth(1500) self.setMaximumWidth(16777215) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.viewer_panel.show() self.was_maximized = not hide_viewer_panel self.updateGeometry() self.adjustSize() self.repaint() if not hide_viewer_panel and self.was_maximized: self.showMaximized()
  • hiding a QLabel at default

    Unsolved 13 Apr 2025, 12:24
    0 Votes
    2 Posts
    259 Views
    Hi and welcome to devnet, How are you setting up your label ? On a side note, I would recommend you take the time to re-evaluate your architecture. Your chain of dialogs is currently pretty brittle. There are other ways to switch from one widget to another that does not involve creating a new widget every time. Check for example QStackedWidget. You might want to also consider QMainWindow which provides a status bar. Depending on the error you might want to consider a QMessageBox using the appropriate level of urgency to show the message.
  • This topic is deleted!

    Unsolved 12 Apr 2025, 06:17
    0 Votes
    1 Posts
    11 Views
    No one has replied