Skip to content

Qt for Python

For discussion and questions about Qt for Python (PySide 2)

3.1k Topics 13.5k Posts
  • 0 Votes
    2 Posts
    14 Views
    jsulmJ

    @markleo said in For large Qt desktop projects, how is the database generally used in combination?:

    Since large databases such as MySQL and PostgreSQL need to be installed on a PC

    Those are typically installed on a server and clients access that server. It would be unusual to install such SQL servers on users machines.

    Whether SQLite is sufficient or not really depends on your needs. It is, for example, not designed to be accessed in parallel by several applications at the same time. So, what are your requirements? Are your clients going to access same databases? If so, you should consider client/server architecture using MySQL/PostgreSQL.

  • 0 Votes
    2 Posts
    2 Views
    jsulmJ

    @markleo Please post error messages as text. In this case the error message is not even completely visible.

  • 0 Votes
    6 Posts
    120 Views
    S

    @SGaist
    Hey, bro.So how can i solve this problem in the win10?or how can i set tooltip backgroundColor in the win10?

  • Can Qt Creator create PyQt project?

    Unsolved
    2
    0 Votes
    2 Posts
    17 Views
    Pl45m4P

    @markleo said in Can Qt Creator create PyQt project?:

    I use Qt Creator to create py project, there is only PySide for choosing.

    As you might have noticed, there are two major Qt Python wrapper libraries: PySide and PyQt.
    PySide is officially developed and maintained by TQtC, whereas PyQt is not.
    Therefore there is no project template for PyQt available in QtCreator.

  • 1 Votes
    2 Posts
    9 Views
    Pl45m4P

    @markleo said in Is there any PyQt demos examples of architecture for modular design of large projects?:

    Does PyQt have similar sample schemes that can be borrowed?

    These are the official PySide Qt examples

    https://doc.qt.io/qtforpython-6/examples/index.html

    and here are some PyQt GitHub examples:

    https://github.com/pyqt/examples
  • Issue with padding/placement PyQT6 Python

    Unsolved
    4
    0 Votes
    4 Posts
    72 Views
    SGaistS

    Something like the following ?

    # code block import sys from PyQt6.QtWidgets import ( QApplication, QMainWindow, QWidget, QVBoxLayout, QPushButton, QStackedWidget, QLabel, QHBoxLayout, QGridLayout ) from PyQt6.QtCore import Qt from PyQt6.QtGui import QIcon, QFont, QFontDatabase class MainWindow(QMainWindow): def __init__(self): super().__init__() # Application Configuration self.resize(800, 600) self.setWindowIcon(QIcon("./Images/clown.ico")) self.setWindowTitle("Recalcitrant V1.0.0") # Create a central widget and main layout self.centralWidget = QWidget() self.setCentralWidget(self.centralWidget) mainLayout = QHBoxLayout(self.centralWidget) # Use QHBoxLayout for side-by-side self.sidebarFrame = self.createSidebarFrame() self.stacked_widget = QStackedWidget() # Create frames self.dashboardFrame = self.createDashboardFrame() self.frame2 = self.create_frame("This is Frame 2") self.frame3 = self.create_frame("This is Frame 3") # Add frames to the stacked widget self.stacked_widget.addWidget(self.dashboardFrame) self.stacked_widget.addWidget(self.frame2) self.stacked_widget.addWidget(self.frame3) # Add sidebar and stacked widget to the main layout mainLayout.addWidget(self.sidebarFrame) # Add sidebar first mainLayout.addWidget(self.stacked_widget) # Then the stacked widget mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) # Set the fixed width for the sidebar self.sidebarFrame.setFixedWidth(150) def createSidebarFrame(self): sidebarWidget = QWidget() sidebarWidget.setObjectName("sidebar") sidebar = QVBoxLayout() sidebar.setAlignment(Qt.AlignmentFlag.AlignTop) # Align sidebar to the top sidebarWidget.setStyleSheet(""" QWidget#sidebar { background-color: #22222E; border-radius: 10px; } QPushButton#button { background-color: #22222E; border: 2px solid #ffffff; border-radius: 10px; padding: 5px; } QPushButton#button:hover { background-color: #393A5A; } QLabel#sidebarLabels { text-align: center; color: white; } """) sidebarWidget.setLayout(sidebar) # Dashboard self.modulesText = QLabel("<div style='text-align: center;'>test</div>") self.modulesText.setObjectName("sidebarLabels") sidebar.addWidget(self.modulesText) self.test = QPushButton("DASHBOARD") self.test.setMaximumWidth(150) self.test.setMinimumWidth(100) self.test.setObjectName("button") self.test.clicked.connect(lambda: self.switch_frame("dashboard")) sidebar.addWidget(self.test) # test self.test = QLabel("<div style='text-align: center;'>test</div>") self.test.setObjectName("sidebarLabels") sidebar.addWidget(self.test) self.test = QPushButton("test") self.test.setMaximumWidth(150) self.test.setMinimumWidth(100) self.test.setObjectName("button") self.test.clicked.connect(lambda: self.switch_frame(1)) sidebar.addWidget(self.test) # test self.test = QLabel("<div style='text-align: center;'>test</div>") self.test.setObjectName("sidebarLabels") sidebar.addWidget(self.test) self.test = QPushButton("test") self.test.setMaximumWidth(150) self.test.setMinimumWidth(100) self.test.setObjectName("button") self.test.clicked.connect(lambda: self.switch_frame(2)) sidebar.addWidget(self.test) sidebar.setContentsMargins(0, 5, 0, 5) #sidebar.setSpacing(0) sidebarWidget.setContentsMargins(0, 5, 0, 5) return sidebarWidget # Return the sidebar widget, not the layout def createDashboardFrame(self): frame = QWidget() frame.setStyleSheet(""" QLabel#label { border: 2px solid #ffffff; border-radius: 10px; padding: 0px; } """) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) frame.setLayout(layout) hbox = QHBoxLayout() layout.addLayout(hbox) test = QLabel("<div style='text-align: center;'>test test</div>") test.setObjectName("label") hbox.addWidget(test) test = QLabel("<div style='text-align: center;'>test test</div>") test.setObjectName("label") hbox.addWidget(test) test = QLabel("<div style='text-align: center;'>test test test</div>") test.setObjectName("label") hbox.addWidget(test) vbox = QVBoxLayout() layout.addLayout(vbox) button = QPushButton("test") vbox.addWidget(button) button = QPushButton("test") vbox.addWidget(button) button = QPushButton("test") vbox.addWidget(button) return frame def create_frame(self, text): """Helper function to create a frame with a label.""" frame = QWidget() layout = QVBoxLayout() label = QLabel(text) layout.addWidget(label) frame.setLayout(layout) return frame def switch_frame(self, index): """Switch to the specified frame.""" if index == "dashboard": self.stacked_widget.setCurrentIndex(0) self.test.setStyleSheet("background-color: #393A5A;") self.test.setStyleSheet("") self.test.setStyleSheet("") elif index == 1: self.stacked_widget.setCurrentIndex(index) self.test.setStyleSheet("") self.test.setStyleSheet("background-color: #393A5A;") self.test.setStyleSheet("") elif index == 2: self.stacked_widget.setCurrentIndex(index) self.test.setStyleSheet("") self.test.setStyleSheet("") self.test.setStyleSheet("background-color: #393A5A;") if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec())
  • Newbie question - connect to label PyQt

    Moved Solved
    8
    0 Votes
    8 Posts
    109 Views
    E

    Thank you @Axel-Spoerl and @JonB , works great and I understood all including lambda. Great help

  • Hi, how to use Qt Designer on macOS?

    Solved
    4
    0 Votes
    4 Posts
    59 Views
    jsulmJ

    @markleo said in Hi, how to use Qt Designer on macOS?:

    I don't find a button called "Design"

    Please look again: it is right there on the left side. It is greyed out because you do not have an ui file yet.

  • 0 Votes
    7 Posts
    138 Views
    SGaistS

    You're likely on Windows 11 and the new windows11 style has some issues.

  • 0 Votes
    1 Posts
    33 Views
    No one has replied
  • 0 Votes
    11 Posts
    143 Views
    JonBJ

    @JimLomax said in Draw lines,arcs at design time then change color on an event at runtime:

    There is no QGraphicsArcItem, the ellipse item can be told to create partial ellipses but I haven't found a way to make it create arcs - it creates pie pieces. 2. Using the QGraphicsPathItem sort of works but I haven't found a way to stop it adding a line to the start of the arc

    I don't have anything to say about QML vs widgets as I only use the latter. But if you are still interested in how to draw an arc on a QGraphicsScene without the pie/line QT QGraphicsScene Drawing Arc shows how to do that.

  • 0 Votes
    4 Posts
    70 Views
    SGaistS

    You're welcome !

    Since this is what you wanted, please mark the thread as solved using the "Topic Tool" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

  • Divide the MainWindow class into smalller classes

    Unsolved
    8
    0 Votes
    8 Posts
    110 Views
    A

    Making everything into custom widgets would be more work that sticking with that big class, but I'll definitely keep this in mind. Thank you both @jsulm and @JonB for help.

  • 0 Votes
    2 Posts
    44 Views
    SGaistS

    Hi,

    It seems you have indeed found something. It's reproducible as well in C++.
    You should open a ticket on the bug tracker with you reproducer (don't forget to check if something similar has already been reported).

  • 0 Votes
    3 Posts
    44 Views
    B

    Hi and thanks for your welcome.
    Good question, I'm trying to create Qt bindings for Ada language.
    Some attempts with C++ were failing due to some C++ subtleties.
    But Python provides C API which I can used easily with Ada.
    I provide some very first Qt bindings for Ada.
    But class inheritance is still in Python.
    I wanted to make them full Ada. I'm able to instantiate a class inherited from QRasterWindow (for instance) but a call to the method metric (for instance) provoques a seg fault.
    (for simplicity I post the code in C)

  • How to properly restart QStateMachine

    Solved
    3
    0 Votes
    3 Posts
    60 Views
    A

    @SGaist

    Thanks

  • 0 Votes
    3 Posts
    64 Views
    H

    That works. If the parent has row() and column() values of -1, then that indicates the parent is the root node.

  • 1 Votes
    4 Posts
    136 Views
    jeremy_kJ

    @Toastito said in How does PyQt5 handle system dark and light mode transitions?:

    The downside is that PyQt5 will still send a palleteChanged signal/event when the system theme changes. Ideally, I would've been able to block it and implement my own.

    I haven't tried, but would expect an event filter to be able to filter out PaletteChange events.

    The QGuiApplication::paletteChanged signal doesn't appear to be connected to anything by default. QObject::disconnect() without a receiver would ensure that, for any existing objects at the time of the call. Note that disconnecting signals at random can have surprising results.

  • A few questions regarding shortcuts

    Moved Unsolved
    12
    0 Votes
    12 Posts
    193 Views
    G

    @jsulm Thank you. I will look into that!

  • 0 Votes
    2 Posts
    58 Views
    SGaistS

    Hi,

    It seems you would need an item on top of your images that you would paint transparently and then use something like QPainterPath to create the shape for your selection. The QGraphicsPathItem might be enough for your needs.

    Hope it helps