Skip to content

Qt for Python

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

3.3k Topics 14.5k Posts
  • cross-compiling pyside2 for AArch64

    Unsolved pyside2 20 Sept 2024, 09:44
    0 Votes
    2 Posts
    308 Views
    This looks like your Qt version is way too old. PySide2 also does not support the platform; please use the current version (PySide 6), see https://doc.qt.io/qtforpython-6/gettingstarted/index.html for cross build instructions.
  • 1 Votes
    7 Posts
    1k Views
    @DieterV said in "corrupted size vs. prev_size while consolidating" or "double free or corruption (!prev)" from thread: I can try to write a compact example that exhibits the same issues to demonstrate what I'm doing That would be nice
  • QTabWidget.tabCloseRequested

    Solved 22 Sept 2024, 13:28
    0 Votes
    7 Posts
    659 Views
    @MasterQ Yes, that allows you to delete whatever widget is on the tab if you wish. However, I don't think a tab has to have a widget, so to prevent error: if widget is not None: widget.deleteLater()
  • QTreeWidget - read/display XML?

    Locked Unsolved 21 Sept 2024, 19:31
    0 Votes
    6 Posts
    668 Views
    @Al3x said in QTreeWidget - read/display XML?: Ive shared all information in my first post. Why start a duplicate topic then? How should anybody know that this is a duplicate? You are wasting the time of voluntary contributors. Duplicate topics are discouraged. Don't do it again. I'll lock this topic. Continue here.
  • 0 Votes
    1 Posts
    239 Views
    No one has replied
  • 0 Votes
    4 Posts
    262 Views
    It seems something in that Driver/SSL tunnel locks up with Python's Global Interpreter Lock.
  • Some .ui files/elements not loading in Python

    Unsolved python 17 Sept 2024, 18:29
    0 Votes
    3 Posts
    618 Views
    Hi, One strange thing is that the error shown is invalid Python. As @JonB suggested, check the exact difference between the two files. Especially if you set this property.
  • PySide6 Property notify signal emit automatically

    Solved 16 Sept 2024, 16:56
    0 Votes
    3 Posts
    557 Views
    @SGaist Thank you
  • 1 Votes
    2 Posts
    1k Views
    Exactly same issue, both at windows and WSL2. 2024 now.
  • Layout problems

    Unsolved 13 Sept 2024, 17:46
    0 Votes
    1 Posts
    145 Views
    No one has replied
  • QWidget method not called on destroyed signal

    Solved 12 Sept 2024, 11:25
    0 Votes
    13 Posts
    787 Views
    @Anonimista atexit.register registered functions/methods are executed on the Python interpreter termination a better solution would be to use weakref.finalize which is called when a LineChart is garbage collected. Here is the current code: import sys import psutil import weakref from PySide6.QtCore import (Qt, QTimer, QThread,QObject, Signal, Slot) from PySide6.QtGui import QPainter from PySide6.QtWidgets import (QMainWindow, QApplication, QWidget, QHBoxLayout) from PySide6.QtCharts import QChart, QChartView, QLineSeries class Worker(QObject): done = Signal(int) def __init__(self, parent=None): super().__init__(parent) @Slot() def get_cpu_load(self): if QThread.currentThread().isInterruptionRequested(): return self.done.emit(psutil.cpu_percent()) class LineChart(QWidget): def __init__(self, parent=None): super().__init__(parent) weakref.finalize(self, self.cleanup) self.worker = Worker() self.thread = QThread() self.worker.moveToThread(self.thread) self.thread.start() self.series = QLineSeries() for i in range(10): self.series.append(i, 0) self.chart = QChart() self.chart.legend().hide() self.chart.addSeries(self.series) self.chart.createDefaultAxes() self.chart.setTitle('CPU load') self.chart.layout().setContentsMargins(0, 0, 0, 0) self.chart.setBackgroundRoundness(0) self.horizontal_axis = self.chart.axes(Qt.Orientation.Horizontal)[0] self.vertical_axis = self.chart.axes(Qt.Orientation.Vertical)[0] self.horizontal_axis.setLabelsVisible(False) self.vertical_axis.setLabelsVisible(False) self.vertical_axis.setMin(0) self.vertical_axis.setMax(100) self.chart_view = QChartView(self.chart) self.chart_view.setRenderHint(QPainter.Antialiasing) self.setLayout(QHBoxLayout()) self.layout().addWidget(self.chart_view) self.timer = QTimer() self.timer.timeout.connect(self.worker.get_cpu_load) self.worker.done.connect(self.update_chart) self.timer.start(500) self.current_time = 19 def update_chart(self, load): self.series.append(self.current_time, load) self.current_time += 1 if self.series.count() > 20: self.series.remove(0) self.horizontal_axis.setMin(self.series.at(0).x()) self.horizontal_axis.setMax(self.series.at(self.series.count() - 1).x()) def cleanup(self): print('in cleanup') self.timer.stop() self.thread.requestInterruption() self.thread.quit() self.thread.wait() class MainWindow(QMainWindow): def __init__(self): super().__init__() self.chart_widget = LineChart() self.setCentralWidget(self.chart_widget) if __name__ == '__main__': app = QApplication(sys.argv) window = MainWindow() window.resize(440, 300) window.show() sys.exit(app.exec())
  • Equivalent to asyncio.sleep?

    Unsolved 8 Sept 2024, 12:04
    0 Votes
    4 Posts
    568 Views
    @Stepan-K said in Equivalent to asyncio.sleep?: You didn't find any better solution than I did I can see - a thread, singleshot timer or blocking shot time.sleep() with processEvents() repeated calling. I did, and told you to use a local QEventLoop with exec() instead of processEvents(). Don't know why you ignored that. That is really the canonical way of doing a "sleep/pause" with Qt event loop processing still allowed. Btw, sleep methods of the Qthread class are blocking I have found, so there likely isn't any difference in using these to an ordinary time.sleep().. I don't understand. You use a "sleep" which blocks the thread --- just what you want between your "command pipeline" being executed in a thread --- but that is fine. The main thread still services the event loop. It's fine to block threads. As for time.sleep() precision, if it's not good enough then use a QTimer. That is what I suggested with the QEventLoop::exec() approach.
  • 0 Votes
    7 Posts
    574 Views
    So we're back to running QML, extended by Python, which makes this topic a duplicate. I'll lock this topic. Follow my advice on https://forum.qt.io/post/808991.
  • the design mode requires a valid qt kit error

    Unsolved 8 Sept 2024, 08:46
    0 Votes
    15 Posts
    1k Views
    ok thank you so much
  • 0 Votes
    6 Posts
    483 Views
    @Pl45m4 OK, I will study it further, Thank you for your help.
  • PyQt5 Widget crashes with custom context menu events?

    Moved Unsolved 5 Sept 2024, 20:46
    0 Votes
    5 Posts
    478 Views
    @MistaGoat05 We are asking you kindly not to post any "pictures" of code or error messages. Therefore you won't be using any "url". "Pictures" of code/messages are too hard to look at, and people need to be able to copy the actual text of stuff to help you out. We are asking you do text copy & paste into your posts here --- preferably inside the forum posts' Code tags, which you can achieve by selecting all the block(s) of code text you are pasting and pressing the </> button --- not any screenshots/pictures.
  • 3 Votes
    27 Posts
    8k Views
    hi, I'm experiencing the same problem but the solution mentioned here is not available for me, the qt version option is disabled for me, at first I didn't have qt5.15 and it was just qt6.7 but then I installed qt5.15 and it still shows the same error and it doesn't allow me to change that qt version option, here kits options: [image: f21edf43-16ff-4a49-a331-a94ac131d36b.png] Qt Creator 14.0.1 Qt6.7 and 5.15 python 3.10.11 windows 11
  • unable to find position that i click on

    Unsolved 6 Sept 2024, 14:16
    0 Votes
    14 Posts
    1k Views
    @Random_userR Yes, I believe third-party is the only way to go. But not sure who that would integrate with QPdfView/QPdfDocument. If you are interested in selected text after click-and-drag, note that QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end) gives a QPdfSelection::boundingRectangle() which has coordinates. I don't know if those values correspond to what your third-party expects. I am also unsure whether to call getSelection() you need the know the coordinates or whether it works if you have just selected an area with the mouse. You'd have to investigate. Certainly do NOT delete this topic, please! Always useful for other people.
  • the Qt6Gui.dll on eventvwr unknown error

    Unsolved 22 Aug 2024, 01:35
    0 Votes
    6 Posts
    2k Views
    The usual rule: don't use global variables, they are usually a sign of architecture issues and become hidden state that are hard to debug and reason about.
  • Animation in pyqt5

    Solved qt for python 6 Sept 2024, 01:10
    0 Votes
    5 Posts
    782 Views
    Got the window flashing removed when the app exits. I changed animation.finished.connect (window.close) to call a function of mine that does the window.close (). When I added a time.sleep (1) after the window.close, it stops that behavior. So it appears qt needs more time when it is cleaning up the window, and when you prematurely interrupt it (with an application exit...), the window repaints for an instant. AND: you don't need to set an initial opacity of 0...