Skip to content

Qt for Python

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

3.2k Topics 14.0k Posts
  • 0 Votes
    6 Posts
    2k Views
    SGaistS

    That's a question for the Qt Company and/or the module maintainers. This is a user forum.
    Note that writing bindings is a non trivial task depending on the underlying types and their lifetime management constraints.

  • 0 Votes
    4 Posts
    724 Views
    JonBJ

    @GrecKo said in Is there any state management library for PySide project?:

    In your example, can both your views share a common model? Alternatively could you have two models sharing some common underlying data?

    @markleo
    Following up this suggestion from @GrecKo. If the models really share the same data you could have that as a single, source model and then impose separate proxy models on top of that for each distinct view. But that relies on a common, shared, base model, not suitable if the models are really quite distinct.

  • 0 Votes
    7 Posts
    146 Views
    SGaistS

    @markleo You have the conda base environment activated but used pip to install pyside6. So which pip did you use exactly ?
    What are the exact step you used ?
    What was the state of your terminal at that time ?

  • 0 Votes
    4 Posts
    150 Views
    M

    I think in Qt there do not need the microkernel architecture.

  • PyQt 6.8 font problem

    Unsolved
    7
    0 Votes
    7 Posts
    4k Views
    M

    Looks I found problem
    PyQt6.7 read font name like "JetBrainsMono NFP" and that's works fine.
    For some reason in PyQt6.8 this does not work and font must set like "JetBrainsMono Nerd Font Propo"

  • Worker class used in GUI is nolonger compatible to Qtimer

    Unsolved
    21
    0 Votes
    21 Posts
    6k Views
    JoeCFDJ

    @ocien 1ms might be too fast for signal/slot to sync. It may not make sense to update your GUI every 1ms. And your CPU will be very busy as well. How about adding a filter(500ms) to show your data. Other data can be cached in case you want to see more.

  • Image files not included in pysidedeploy build

    Unsolved
    1
    0 Votes
    1 Posts
    61 Views
    No one has replied
  • pyside6-deploy - QtMultimedia

    Solved
    4
    0 Votes
    4 Posts
    75 Views
    S

    multimedia should have automically been added to the plugins by the tool itself (atleast in 6.8.1 as i check with an example). So, if anyone stumbles upon this, please use the latest version of PySide6 and check.

  • PySide6 gets stuck in QtWidget.setVisible()

    Solved
    4
    0 Votes
    4 Posts
    72 Views
    JonBJ

    @LingHan said in PySide6 gets stuck in QtWidget.setVisible():

    I should redesign my program and use front-end code to call my back end algorithms, rather than the other way around.

    Yes. You should create a single QApplication instance and call QApplication.exec() as the last step from main(). It does not return until the user quits. All your UI code must be in the main thread, the one where the QApplication is created. You can do background/computation code in secondary threads, either long running one(s) or short-lived. The Qt thread code runs an event loop in each thread, so you can send it signals (e.g. to start something off) and it can send signals back to your main (e.g. when it has finished something or wants the UI to show something on its behalf).

  • QSizePolicy doesnt work

    Unsolved
    4
    0 Votes
    4 Posts
    66 Views
    R

    it worked, i realized my QVlayout was just floating in the window, so i attached it to the window with grid layout.
    https://stackoverflow.com/questions/3492739/auto-expanding-layout-with-qt-designer

  • How set Title of QgroupBox to bold

    Unsolved
    11
    0 Votes
    11 Posts
    200 Views
    M

    @JonB Oh no another option

  • "Sharp" scaling for high DPI?

    Unsolved
    1
    0 Votes
    1 Posts
    39 Views
    No one has replied
  • 1 Votes
    5 Posts
    93 Views
    CKurduC

    Thank you for your answers,
    It appears I made a simple mistake in the actual code.
    The garbage collector removed the object. Additionally, when an error occurs, it emits a signal immediately, and my connection isn't functioning as @GrecKo described.

  • Python coding for stacked widget

    Unsolved
    2
    0 Votes
    2 Posts
    45 Views
    SGaistS

    Hi and welcome to devnet,

    What are these pages ?
    Are the pages all the same widget or each page has its own widget ?

  • QMessageBox not working

    Unsolved
    3
    0 Votes
    3 Posts
    95 Views
    sierdzioS

    I guess you need to use msg.show().

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Problems with QMenu and QSystemTrayIcon

    Unsolved
    7
    0 Votes
    7 Posts
    184 Views
    M

    Here's an example I've made that anyone can run, you will need to replace self.path_to_tray_image to a path of an image in order for it to actually appear in the system tray.

    self.path_to_tray_image = "C:/Users/username/Downloads/image.png" import sys from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QSystemTrayIcon, QMenu from PyQt6.QtCore import QPoint from PyQt6.QtGui import QIcon, QAction, QCursor class TrayApplication(QMainWindow): def __init__(self): # replace to your tray image self.path_to_tray_image = "C:/Users/username/Downloads/image.png" super().__init__() self.setWindowTitle("Tray Example") self.setGeometry(100, 100, 400, 300) # Create a button to minimize to tray self.minimize_button = QPushButton("Minimize to Tray", self) self.minimize_button.setGeometry(150, 120, 100, 40) self.minimize_button.clicked.connect(self.minimize_to_tray) # Set up the system tray icon self.tray_icon = QSystemTrayIcon(self) self.tray_icon.setIcon(QIcon(self.path_to_tray_image)) # Replace with your icon file # Add a context menu to the tray icon self.tray_menu = QMenu() quit_action = QAction(QIcon(":/path_to_exit_action_image"), "Quit", self) # Replace with your icon file quit_action.triggered.connect(self.close_application) self.tray_menu.addAction(quit_action) # Connect the tray icon activation event self.tray_icon.activated.connect(self.tray_icon_clicked) def minimize_to_tray(self): self.hide() self.tray_icon.show() def restore_from_tray(self): self.show() self.tray_icon.hide() def tray_icon_clicked(self, reason): # Left click if reason == QSystemTrayIcon.ActivationReason.Trigger: self.restore_from_tray() # Right click elif reason == QSystemTrayIcon.ActivationReason.Context: # Get the current cursor position cursor_pos = QCursor.pos() # Calculate the menu position: align bottom-right corner of the menu to the cursor menu_width = self.tray_menu.sizeHint().width() menu_height = self.tray_menu.sizeHint().height() pos = QPoint(cursor_pos.x() - menu_width, cursor_pos.y() - menu_height) # Show the menu at the calculated position self.tray_menu.popup(pos) def close_application(self): self.tray_icon.hide() self.close() if __name__ == "__main__": app = QApplication(sys.argv) window = TrayApplication() window.show() sys.exit(app.exec())
  • does pyside deploy encrypt source code?

    Unsolved
    3
    0 Votes
    3 Posts
    94 Views
    H

    pyside6-deploy doesn't encrypt your source codeā€”it packages it into the executable. To protect the code, you might want to obfuscate it using tools like pyarmor or [cython](https://syntaxscenarios.com/python/scientific-notation/).

    For the QML and image files issue, you can include them in the executable by modifying your .spec file if you're using PyInstaller. Add:

    datas = [ ('qml', 'qml'), ('images', 'images') ]

    Then in the Analysis section:

    a = Analysis( ['main.py'], datas=datas, ... )

    This ensures the QML and images are bundled inside the executable. Let me know if you need further clarification!

  • pyqt6-tools depends on pyqt6-plugins

    Unsolved
    5
    0 Votes
    5 Posts
    791 Views
    M

    @JETouma Can you solve the problem?

  • Issue with PyInstaller Executable Not Finding Internal DLL

    Unsolved
    2
    0 Votes
    2 Posts
    79 Views
    O

    The issue was that I had python311.dll but didn't have python3.dll. Adding the python3.dll file resolved the problem.