Skip to content

Qt for Python

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

3.3k Topics 14.5k Posts
  • Dynamic Image Scaling Widget

    Unsolved
    5
    0 Votes
    5 Posts
    605 Views
    JonBJ
    @andrei_cp Maybe your resetting the pixmap to a new size in resizeEvent() in turn causes a new size event, and a bit bigger than before? That is the recursion. In any case I imagine you want to use @friedemannkleint's suggestion, then you only need the label to resize, see if that helps.
  • 0 Votes
    4 Posts
    351 Views
    F
    QGuiApplication is a bit smaller...
  • Avoid unnecessary repaints

    Unsolved
    2
    0 Votes
    2 Posts
    310 Views
    JoeCFDJ
    You may try: get visial rect of the item QRect QTableWidget::visualItemRect(const QTableWidgetItem *item) const update it only void QWidget::update(const QRect &rect) check here out https://www.qtcentre.org/threads/1032-repaint-a-cell-or-row-in-QTableWidget
  • QPdfDocument.Error.None : syntax error in Python

    Solved
    3
    0 Votes
    3 Posts
    347 Views
    G
    Thank you very much !
  • 0 Votes
    4 Posts
    714 Views
    M
    Out of curiosity, have you tried building this with "pure" nuitka (not via pyside6-deploy)? I have completely given up on pyside6-deploy, but never really have any problems with nuitka for any platform.
  • PyQt5 - possible to recreate the application main window at runtime?

    Solved
    4
    0 Votes
    4 Posts
    397 Views
    SGaistS
    I meant it's achieved internally so you don't have to do anything special unless you are doing your own rendering. QScreen would be of interest.
  • [PySide6] Slot Executed in Signal's Thread Even With Auto & QueuedConnection

    Moved Solved
    13
    0 Votes
    13 Posts
    2k Views
    T
    @Pl45m4 Thanks for your explanation! I'll keep you posted if I find out something new on this topic.
  • PyQt6 6.8.0 in PyCharm, when I run the debugger, the app crashes.

    Unsolved
    3
    0 Votes
    3 Posts
    398 Views
    M
    @JonB I'm actually using the latest PyCharm version. This only happens with the latest PyQt6 version 6.8.0, and works fine with PyQt6 6.7.1, so it's probably an issue with the latest PyQt6 version, not the IDE.
  • Hover color appears when restoring window from taskbar on Windows

    Unsolved
    1
    0 Votes
    1 Posts
    117 Views
    No one has replied
  • PySide6 Unsupported keyword on Grid Layout

    Unsolved pyside qt for python python
    9
    0 Votes
    9 Posts
    821 Views
    JonBJ
    Well it's nice to know it's in good hands :)
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • 0 Votes
    1 Posts
    117 Views
    No one has replied
  • Release a Qpdf without loading a new one

    Solved qt for python python pyside
    11
    0 Votes
    11 Posts
    1k Views
    A
    I've finally found the solution, it was indeed the eventloop. The process will only be destroyed after the next loop. match_manager.py # Mettre à jour les variables dans le fichier Excel ExcelToPdfWorker.update_variables(excel_path, variables) # Connecter le signal avant de décharger le PDF match_widget.editor.pdf_unloaded.connect( lambda: self._convert_after_unload(match_widget, excel_path) ) match_widget.editor.unload_pdf() def _convert_after_unload(self, match_widget, excel_path): """Appelé quand le PDF est vraiment déchargé.""" self.excel_worker.excel_path = excel_path self.excel_worker.convert() # Une fois la conversion terminée, on peut recharger le PDF match_widget.editor.load_new_pdf(match_widget.pdf_path) editor.py def unload_pdf(self): """Ferme le PDF actuel et nettoie les références.""" # Détacher la vue du document actuel self.pdfView.setDocument(None) # Fermer et supprimer l'ancien document if self.pdfDocument: old_document = self.pdfDocument # Créer un nouveau document vide avant de détruire l'ancien self.pdfDocument = QPdfDocument(self) # Connecter le signal destroyed à l'émission de notre signal old_document.destroyed.connect(self.pdf_unloaded.emit) old_document.close() old_document.deleteLater() def load_new_pdf(self, pdf_path): """Charge un nouveau fichier PDF.""" # Charger le nouveau PDF self.pdfDocument.load(pdf_path) self.pdfView.setDocument(self.pdfDocument) print(f"Nouveau PDF chargé: {pdf_path}") return True I'm well aware that my code sucks. Here's the solution. As deleteLater() really destroy the PdfDocument and unload it, you have to wait until the end of a complete cycle and return to app.exec(). Then I put in a signal that will convert the file once the reference has been destroyed, since we know that this frees access You should know that I think this is the only method without making temporary files
  • How can I add other widgets by pressing a button on PyQt5?

    Unsolved
    6
    0 Votes
    6 Posts
    716 Views
    C
    Thank you for all the help guys! I just needed to search about "Adding new widgets dynamically", but I didn't know it was called like this. This is the final result: def addRow(self, r): self.newLayoutRow = QtWidgets.QHBoxLayout() self.newLayoutRow.setObjectName("newLayoutRow_" + str(r)) self.newTimeEdit = QtWidgets.QTimeEdit(self.sorting0) self.newTimeEdit.setObjectName("newTimeEdit_" + str(r)) self.mainGrid.addWidget(self.newTimeEdit, r, 0, 1, 1) self.QComboBox1 = QtWidgets.QComboBox(self.sorting0) self.QComboBox1.setObjectName("QComboBox1_" + str(r)) self.newLayoutRow.addWidget(self.QComboBox1) self.QComboBox2 = QtWidgets.QComboBox(self.sorting0) self.QComboBox2.setObjectName("QComboBox2_" + str(r)) self.newLayoutRow.addWidget(self.QComboBox2) self.QSpinBox = QtWidgets.QSpinBox(self.sorting0) self.QSpinBox.setObjectName("QSpinBox_" + str(r)) self.newLayoutRow.addWidget(self.QSpinBox) self.mainGrid.addLayout(self.newLayoutRow, r, 1, 1, 1) Now just need to add some for loops and it's good to go
  • Different file explorer dependent on how application is started.

    Unsolved
    7
    0 Votes
    7 Posts
    695 Views
    JonBJ
    @Dwarrel Well it kind of is the solution, in that you want to compare the two both running with the same PYTHONPATH.
  • About ending the program and backing to the first page

    Unsolved
    5
    0 Votes
    5 Posts
    345 Views
    JonBJ
    @jack_8390 As @SGaist has said. You still have said mothing about what your "pages" actually are or how the user moves between them. If your process is for each user to step through sequential pages to perform their actions/turns and then return to the start of these pages totally afresh for the next user you might consider Qt's QWizard Class, which supports stepping forward (and optionally, but not necessarily, backward) through a bunch of QWizardPage pages. This supports restarting where it resets any previously entered information on the pages so that they start afresh if that is what you want. Otherwise you need to write your own code to reset existing content as @SGaist has said. Or destroying existing used pages and recreating them anew to get them back to their original state.
  • How to use QDesignerCustomWidgetInterface.registerCustomWidget()

    Unsolved
    6
    0 Votes
    6 Posts
    453 Views
    S
    @friedemannkleint Yes, the rc_file is imported automatically by NumKeyboard_ui.py when I use the image from resources, Edit: After I modify the "*_ui.py" generated by pyside6-uic: # import resources_rc from . import resources_rc # change to relative import. The custom widget works well in Designer.
  • Where do I find pyside6-deploy?

    Solved
    9
    0 Votes
    9 Posts
    4k Views
    SGaistS
    Hi and welcome to devnet That's a question you should bring the maintainers of the conda PySide6 recipe.
  • Loading images of qt designer in python

    Unsolved
    4
    0 Votes
    4 Posts
    458 Views
    jsulmJ
    @jack_8390 "The workflow with pyqt6 for me is like this" - so yes
  • Image files not included in pysidedeploy build

    Unsolved
    2
    0 Votes
    2 Posts
    244 Views
    CristianMaureiraC
    For the .qrc approach to work, which is what we recommend, to do the following: If you have icons/ in the root of your project, then add to your .qrc file needs to have entries like: <file>icons/1.png</file>, and then when you generate the .py file out of it, you import it in the file you want to use, and refer to the files like :/icons/1.png. More information in https://doc.qt.io/qtforpython-6/tutorials/basictutorial/qrcfiles.html#tutorial-qrcfiles With that, pyside6-project will pick them automatically. The <name>.pyproject file is only a construct for QtCreator to open projects, and it's not related to pyside6-deploy