Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • Strange delay for starting pyside6-deploy packaged app

    Unsolved
    4
    0 Votes
    4 Posts
    466 Views
    CristianMaureiraC
    @Antonio-C compared to a normal PySide application, how long does that take? pyside6-deploy uses Nuitka under the hood. It really compiles the Python code, creating C-based python extensions, so there might be some heavy lifting to make sure all the Qt dependencies are in place. Do you see a similar approach in other compiled apps? I haven't experience this at least on Linux.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    18 Views
    No one has replied
  • Python script not exit

    Moved Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    jsulmJ
    @bebewinla if len(sys.argv) != 3: print ("usage my.py [filename] [sourcefile]") sys.exit(app.exec()) If you want to exec this script here, then why are you starting Qt event loop calling app.exec()?! app.exec() is a blocking call and does NOT return until Qt event loop is terminated. There is absolutely no need to start Qt event loop if you want to exit the script...
  • Submitting to mac store

    Unsolved
    4
    1 Votes
    4 Posts
    477 Views
    A
    @pedruu have you sorted it out? were you able to publish your app to the Mac App Store? Could you provide the link to the app?
  • QSqlTableModel - distinguish between existed and new table rows

    Solved
    4
    0 Votes
    4 Posts
    358 Views
    S
    @SGaist , ok thanks. So I created QTBUG-115145 with this proposal, lets see. This topic is solved.
  • Can't return right win ID on wayland

    Unsolved
    3
    0 Votes
    3 Posts
    443 Views
    T
    I found a bug report talks about this problem https://bugreports.qt.io/plugins/servlet/mobile#issue/QTBUG-76983
  • Pyqt scatter mapbox - Not able update selected values in figure.

    Moved Unsolved
    1
    0 Votes
    1 Posts
    166 Views
    No one has replied
  • PyQt6 QMediaRecorder recording no sound

    Unsolved
    3
    0 Votes
    3 Posts
    491 Views
    A
    @SGaist Hi, that's what I get : Device: USB Audio Analog Stereo Device: Alder Lake PCH-P High Definition Audio Controller Headphones Stereo Microphone Device: Alder Lake PCH-P High Definition Audio Controller Digital Microphone defaultDevice: USB Audio Analog Stereo Id b'alsa_input.usb-Generic_USB_Audio-00.analog-stereo' <PyQt6.QtMultimedia.QAudioDevice object at 0x7fda87807ed0> from: devices = QMediaDevices.audioInputs() for device in devices: print("Device: ", device.description()) defaultdevice = QMediaDevices.defaultAudioInput() print("defaultDevice: ", defaultdevice.description(), "Id ", defaultdevice.id()) print(QMediaDevices.defaultAudioInput())
  • QGraphicsObjects as QAbstractItemModel items: RuntimeError

    Solved
    7
    0 Votes
    7 Posts
    569 Views
    jeremy_kJ
    I've given up on custom models for PyQt/PySide use, instead embracing QStandardItemModel. Unless there is significant compute intensive translation required to maintain state with a non-QAbstractItemModel representation, python code is unlikely to be anywhere near as performant. QStandardItemModel has presumably had any major item model defects worked out long ago (I didn't check the bug tracker...) I don't use the QStandardItem subclassing pattern demonstrated in some of the documentation. That reintroduces the potential for item model interface mistakes, and degraded performance from the python interpreter. Custom roles have been sufficient for any non-standard data that I've wanted to store.
  • showNormal() makes the app stuck

    Unsolved
    8
    0 Votes
    8 Posts
    742 Views
    JonBJ
    @Prabhav As @SGaist says. When you have an issue which you cannot reproduce in a minimal example and only happens in some complex code you know that it is going to have something to do with that code and that nobody will be to answer without seeing it! It is a "shame" if you have many threads, that's often not needed in a Qt application, may be overused by beginners and is a frequent source of errors. "Intermittent" behaviour can often happen in thread cases, where the order of operations may vary over time. The first thing to make sure is that no code in your threads accesses (read or write) anything in the UI. That is not allowed in Qt and leads to undefined behaviour. For example (just an example) if the two lines of code you show are executed from a thread (i.e. called directly, not via a signal which the main window has attached a slot to) that would be a no-no. But even if this call is made correctly, if anything else infringes the rule all bets are off for the state of the UI.
  • Could not load the Qt platform plugin "xcb" in "" even though it was found

    Unsolved
    7
    0 Votes
    7 Posts
    3k Views
    SGaistS
    @jaaf hi, The user in your docker container is root which by default has no access to the X server for security reasons. You can use the xhost command to manipulate these permissions.
  • Can't show the border of the class inheriting QWidget class

    Solved
    11
    0 Votes
    11 Posts
    2k Views
    C
    @JoeCFD Yes, I have read the post at https://forum.qt.io/topic/29555/how-to-set-border-on-a-widget and it suggests using QFrame or styleSheet. And when I use Qt C++, both two suggestions work fine. However, Python does not. That makes me feel confused. I can't understand why my Qt C++ code can work well but both PySide6 and PyQt6 can not. Therefore, I think I was wrong somewhere and I posted it to find help. But that may be the difference between the two languages.
  • QMidArea Tab options?

    Unsolved
    2
    0 Votes
    2 Posts
    312 Views
    Z
    Hi, self.mdiAreaTabBar = self.findChild(QTabBar) typing.cast(QTabBar, self.mdiAreaTabBar).setExpanding(False)
  • How to recreate a necessary and minimal virtual env

    Moved Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    JonBJ
    @jaaf Then you can ignore the .ui file. The only thing that runs is the .py file. That will include whatever tab is selected initially from Designer. Check the code in that, play with it for different behaviour. My guess is whatever you are/are not seeing is to do with Qt6 rather than PyQt6. If behaviour varies between virtual environments examine what could be different. Possibly a change in path/files picked up.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • QDataVisualization

    Solved
    7
    0 Votes
    7 Posts
    726 Views
    SGaistS
    Since you have it working now please mark the thread as solved using the "Topic Tools" button or the three doted menu beside the answer you deem correct so that the other forum members may know a solution has been found.
  • Change color of part of the text in a QListWidgetItem

    Solved
    8
    1 Votes
    8 Posts
    2k Views
    K
    @SGaist Seems to work well enough, although I share the sentiment in the SO post that this seems a bit hacky for such an important functionality. There are many "solutions" provided in the post, I ended up using this answer, which worked for PySide6 after adapting some imports. Thank you both for your time :) Adapted solution (in case linked post gets lost) from PySide6.QtCore import QRectF, QSize from PySide6.QtGui import QTextDocument, QAbstractTextDocumentLayout from PySide6.QtWidgets import QStyledItemDelegate, QStyleOptionViewItem, QStyle # https://stackoverflow.com/a/66091713 class HTMLDelegate(QStyledItemDelegate): def __init__(self): super().__init__() # probably better not to create new QTextDocuments every ms self.doc = QTextDocument() def paint(self, painter, option, index): options = QStyleOptionViewItem(option) self.initStyleOption(options, index) painter.save() self.doc.setTextWidth(options.rect.width()) self.doc.setHtml(options.text) self.doc.setDefaultFont(options.font) options.text = '' options.widget.style().drawControl(QStyle.ControlElement.CE_ItemViewItem, options, painter) painter.translate(options.rect.left(), options.rect.top()) clip = QRectF(0, 0, options.rect.width(), options.rect.height()) painter.setClipRect(clip) ctx = QAbstractTextDocumentLayout.PaintContext() ctx.clip = clip self.doc.documentLayout().draw(painter, ctx) painter.restore() def sizeHint(self, option, index): options = QStyleOptionViewItem(option) self.initStyleOption(option, index) self.doc.setHtml(option.text) self.doc.setTextWidth(option.rect.width()) return QSize(self.doc.idealWidth(), self.doc.size().height())
  • threading module in pyqt desktop app

    Unsolved
    3
    0 Votes
    3 Posts
    288 Views
    P
    @JonB I understand, Thanks Jon !
  • String Date to Julian Date

    Unsolved python pyside qt for python
    2
    0 Votes
    2 Posts
    365 Views
    JonBJ
    @britesc How about doing this in Python, nothing to do with Qt? Maybe https://stackoverflow.com/questions/53107367/convert-calendar-date-to-julian-date-python ?
  • 0 Votes
    3 Posts
    360 Views
    J
    @SGaist Controlling some peripherals, such stepper motor and going through a device calibration procedure. I have sorted out the issue by adding queue inside of my GStreamer pipeline, however, I am still wondering why would this happen when the QThread worker is running...