Skip to content

Qt for Python

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

3.3k Topics 14.4k Posts
  • pyside6-deploy - QtMultimedia

    Solved
    4
    0 Votes
    4 Posts
    241 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
    227 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
    196 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
    463 Views
    M

    @JonB Oh no another option

  • "Sharp" scaling for high DPI?

    Unsolved
    1
    0 Votes
    1 Posts
    101 Views
    No one has replied
  • 1 Votes
    5 Posts
    228 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
    130 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
    218 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
    325 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
    187 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
    1k Views
    M

    @JETouma Can you solve the problem?

  • Issue with PyInstaller Executable Not Finding Internal DLL

    Unsolved
    2
    0 Votes
    2 Posts
    570 Views
    O

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

  • How to make QPainter elements clickable-through using PyQt

    Unsolved
    11
    1 Votes
    11 Posts
    3k Views
    enjoysmathE

    @igonro That's the sexiest MWE I've ever "scene"!

  • Please solve this problem

    Unsolved
    4
    0 Votes
    4 Posts
    156 Views
    jsulmJ

    @parth07sm Then read "Selecting a mirror for opensource" in https://wiki.qt.io/Online_Installer_4.x - it even shows what to do.

  • 0 Votes
    1 Posts
    61 Views
    No one has replied
  • ModernGL with QOpenGLWidget isn't rendering

    Solved
    6
    0 Votes
    6 Posts
    438 Views
    jsulmJ

    @ktechhydle If you enter "qt6 QWindow OpenGL" in Google first result is: https://doc.qt.io/qt-6/qtopengl-openglwindow-example.html

  • BLE Peripheral Requirements for Mac & Windows

    Unsolved
    1
    0 Votes
    1 Posts
    85 Views
    No one has replied
  • Fast loading of complex interfaces

    Solved
    6
    0 Votes
    6 Posts
    299 Views
    Q

    @JonB said in Fast loading of complex interfaces:

    Just one thing: let's say you leave it as-is because you don't want to divide it for whatever reason. Are you at least aware that Qt has a QSplashScreen?

    Didn't know that. I'll use it. tnx

    @jsulm said in Fast loading of complex interfaces:

    you can still design ui widgets for different parts of the user interface using designer.

    I think I'll do what you wrote. Thank you.

  • How to add data files in nuitka

    Unsolved
    5
    0 Votes
    5 Posts
    414 Views
    M

    @Shyamnath How do I add project data files (images and QML files) to the pysidedeploy.spec file so that the generated executable file can be run anywhere?Because my data files are not being added.