Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • This topic is deleted!

    Moved Unsolved
    3
    0 Votes
    3 Posts
    26 Views
  • HMI and PyQt5 Slider Connection

    Unsolved
    2
    0 Votes
    2 Posts
    352 Views
    SGaistS
    Hi, You are mixing quite a lot of different technologies here. Since you already have React in your web part, why not implement the rest of the UI there as well ?
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 1 Votes
    6 Posts
    6k Views
    T
    So I found a bugreport describing an undocumented call that did the trick: QApplication.shutdown() Described here: https://bugreports.qt.io/browse/PYSIDE-1190 By calling that after the exec() returns, we are able to re-open the Dialogs again when the code is executed.
  • Getting error 'Could not parse stylesheet of object QGroupBox'

    Solved
    3
    0 Votes
    3 Posts
    424 Views
    A
    @sanqi Ouch! I don't know what I was thinking as I went over the snippet several times but didn't notice. Thanks.
  • 0 Votes
    4 Posts
    597 Views
    T
    @CristianMaureira Thanks I do it now like you said it, and added a comment for PyCharm IDE to not remote these imports when I run the Optimize Imports Refactoring tool. # noinspection PyUnresolvedReferences from src.examples import CpuLoadModel, NumberGeneratorSignalbased, NumberGeneratorPropertiesbased, UserModel # noinspection PyUnresolvedReferences from src import RecipesModel
  • Still confused when passing parameters to subclass/signal-slot

    Solved
    6
    0 Votes
    6 Posts
    605 Views
    jeremy_kJ
    @JuanW said in Still confused when passing parameters to subclass/signal-slot: @jeremy_k, Thank you so much, it works. I though the "None" in parameter index=None means to set the index value as None when I do not pass any value to it. Do that for the declaration rather than invocation. EG class Foo: def __init__(self, index = None): pass Foo() # index is None Foo(0) # index is 0
  • PyQt5 application segmentation fault in Linux but not Windows

    Unsolved
    5
    0 Votes
    5 Posts
    797 Views
    jsulmJ
    @oarcelus said in PyQt5 application segmentation fault in Linux but not Windows: How could I create a stacktrace (following the previous answer)? Just run your application in a debugger - as soon as it crashes debugger will show the stack trace
  • pyside6-deploy build error ...

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    Malvin LokM
    I am not using pyside6-deploy and just using the raw nuitka command, had built an executable file successfully. here is my commands: python -m nuitka \ --standalone \ --enable-plugin=pyside6\ --macos-create-app-bundle\ --macos-app-icon=./resource/icons/icons.icns\ --output-dir=$BUILD_PATH\ --assume-yes-for-download\ --macos-app-name=$APP_NAME\ --disable-console \ main.py but I don't use QML.
  • Trying to Connect QML Signal to PySide6 Slot using QQuickWidget

    Solved
    3
    0 Votes
    3 Posts
    532 Views
    I
    I was able to get it to run by moving the root connect code to the bottom of init. after central widget. DOES ANYONE KNOW WHY IT WORKS WHEN I ADD SIGNAL CONNECTOR AFTER SETTING THE CENTRAL WIDGET? import os from pathlib import Path import sys from PySide6.QtCore import QUrl, Slot from PySide6.QtGui import QGuiApplication from PySide6.QtQuick import QQuickView from PySide6.QtQuickWidgets import QQuickWidget from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QMainWindow @Slot(float) def sayThis(s): print(s) class MainApp(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): wt = QQuickWidget() ml_file = os.fspath(Path(__file__).resolve().parent / 'view1.qml') wt.setSource(QUrl.fromLocalFile(ml_file)) self.setCentralWidget(wt) self.root = wt.rootObject() self.root.textRotationChanged.connect(sayThis) if __name__ == "__main__": app = QApplication(sys.argv) window = MainApp() window.show() sys.exit(app.exec())
  • I can't open .qml in vscode

    Solved
    8
    0 Votes
    8 Posts
    2k Views
    T
    @jsulm lol thank you very much. I would never imagine that it would be because the file was empty. By default this usually doesn't happen and when you open a file and there's an error it's because something isn't working, so I thought it wouldn't even work[image: 91a22797-f3e2-4c34-9bf7-a19e6695d811.jpg]
  • How to get actual size of item in QGridLayout?

    Moved Unsolved qgridlayout qwidget size sizepolicy sizehint
    2
    0 Votes
    2 Posts
    765 Views
    C
    @Hai-Anh-Luu Welcome to the forum. Until the widget is displayed its size, and the size of any child widget in a layout, is unknown. In the widget class constructor^^ the widget is not yet shown so you get either the size hint from the widget concerned or some other value. ^^ That is when executing this line window = NewGrid() One way to see the size that is initially allocated is to do so in a slot connected to a zero-length (or very short) single-shot QTimer. This will fire when the event loop is reached, after the UI is shown. That is when app.exec() is running.
  • Weird behavior for ScrollArea with Grid layout after ~195 widgets

    Unsolved pyside qt for python
    4
    0 Votes
    4 Posts
    765 Views
    SGaistS
    @Niccolo-v showing the videos would require a custom delegate. As for the issue with a high count of widget, I can't comment without a reproducer.
  • QT Design Studio & Python

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    P
    @JKSH said in QT Design Studio & Python: See https://www.qt.io/blog/qt-for-python-6.5 it has a link to the example and tutorial below: https://doc-snapshots.qt.io/qtforpython-dev/examples/example_quickcontrols_filesystemexplorer.html This link provides a number of files and folders as a ZIP file, including filesystemexplorer.py. When I run filesystemexplorer.py, the application window appears and all features work. That's great. But how can I generate all these files, including the corresponding Python script, if I want to run my own Design Studio project from Python? Is there a tutorial or documentation for this workflow?
  • Pyside6 6.6.1: References to QRingBuffer in private API are undefined

    Unsolved
    3
    0 Votes
    3 Posts
    479 Views
    D
    @SGaist The system administrator installed Pyside6. I'll try to get more information from them about how it was done.
  • Line Moves Around before finding Center

    Moved Solved
    4
    0 Votes
    4 Posts
    426 Views
    Pl45m4P
    @oldguardmd said in Line Moves Around before finding Center: I think this person tried to explain why this happens in a Stack Overflow discussion, but I admit that I am still struggling to understand everything they are saying here: I thought it could be an issue with your sceneRect but wasn't quite sure. Sometimes you want a fixed scene and sometimes you need it dynamic. Say your QGraphicsView is a window (a glass window, not a program window) and the QGraphicsScene is, well, a scene/everything you see through the window. The scene, the world outside, can be (or IS) bigger than the part you see when you look through the window. What you see depends on how your window (the GView) and our environment (the GScene) are aligned. Your frame starts at (0 / 0) topleft, but this doesn't mean the topleft point, you "grab" when reaching through your window, is the origin of your environment. (see Coordinate Mapping) With no sceneRect (= part of the "world" you want to focus on) the QGraphicsView sets up the scene so that is it centered around your items. And will try to maintain this, when items are moving (which is the case here). As soon as your spinning line comes close to the edge of the visible area (viewPort), the scene will expand and adjust. Probably scrollBars will appear too. If you set your items for whatever reason to positions like ( 800 / 800 ), the scene will adjust to that area. When specifying a static sceneRect these adjustments wont occur, but you have to keep track of your items yourself... if they move out of your visible area, they are "gone" until you move them back in or adjust the viewport. Also the scene only grows, but never shrinks by itself. If you set items to ( -100, -100) and (9000 / 9000) you end up with a pretty huge scene, even if you move both items very close to the origin later. This is with no fixed scene... (automatically centered viewport around the items at t=0) you can see the viewport "jumping" as the line hits the top edge. [image: 02dd0c9b-046e-4f17-a6cd-adbdae78004c.gif] Same code, but fixed scene here (a bit off because of the circle I painted around the spinning line) [image: d962ce55-e794-4834-b038-b56fb9df2cad.gif] Hope things became more clear :) Here is the official Qt GraphicsView documentation https://doc.qt.io/qt-6/graphicsview.html
  • Undesired padding in a right docked dockWidget

    Unsolved
    3
    0 Votes
    3 Posts
    335 Views
    F
    Hello. I have not a layout. Is it this the issue? I've tried to write a simple main.py code to run. I have the same issue wiht undesired padding both on the left and on the right side: [image: 5de14130-758b-40d0-9be4-77fe0349e8b0.png] Here is the code. Thank you in advance for the help: from PyQt5.QtWidgets import * from PyQt5.QtCore import * import sys class MainWindow(QMainWindow): def init(self): super().init() self.initUI() def initUI(self): self.setObjectName("MainWindow") self.move(400, 100) self.resize(1000, 600) # Central Widget - MdiArea self.mdiArea = QMdiArea() self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.mdiArea.setViewMode(QMdiArea.TabbedView) self.mdiArea.setTabsClosable(True) self.mdiArea.setTabsMovable(True) self.mdiArea.setMinimumWidth(50) self.setCentralWidget(self.mdiArea) # List Widget on the left side self.listLeftSide = QListWidget() self.DocListLeft = QDockWidget("Test - Left Side") self.DocListLeft.setFeatures(self.DocListLeft.DockWidgetClosable) self.DocListLeft.setMinimumWidth(250) self.DocListLeft.setMaximumWidth(400) self.addDockWidget(Qt.LeftDockWidgetArea, self.DocListLeft) # Dock Widget on the right side self.dockWidget = QDockWidget("Test - Rigth Side") self.dockWidget.setFeatures(self.dockWidget.DockWidgetClosable) self.dockWidget.setAllowedAreas(Qt.RightDockWidgetArea) self.dockWidget.setMinimumWidth(250) self.dockWidget.setMaximumWidth(400) self.addDockWidget(Qt.RightDockWidgetArea, self.dockWidget) if name == 'main': app = QApplication(sys.argv) wnd = MainWindow() wnd.show() sys.exit(app.exec_())
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Creating Qt6 anaconda package always errors out

    Unsolved
    9
    0 Votes
    9 Posts
    2k Views
    SGaistS
    Thanks for the links !
  • Transpanrent effect isn't working well with QScrollArea

    Moved Unsolved
    1
    0 Votes
    1 Posts
    155 Views
    No one has replied