Skip to content

Qt for Python

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

3.2k Topics 14.2k Posts
  • 0 Votes
    2 Posts
    38 Views
    JonBJ

    @dev-anis
    If you do not get an answer here, don't forget PyQt is third-party. They have mailing list if you need to ask there.

  • QT Quick with python

    Solved
    8
    1 Votes
    8 Posts
    215 Views
    I

    I think I finally understand how .ui.qml, .qml and python backend should work together when working with QDS project.
    Way I did this was to export component ID as property alias in QDS by clicking @ sign, as shown on screenshot:
    Screenshot 2025-02-05 181658.png

    Then this alias should be used in .qml files, such as App.qml in order to access the component in .ui.qml (This was the biggest confusion point for me). Then we can use signals and slots to connect components with backend as usual.

    I created a minimal example and can be seen here in case anyone has same issue.
    https://github.com/irakliskhirtladze/QML-Demo

  • qmenu black mark in corner . how to remove it

    Moved Unsolved
    6
    0 Votes
    6 Posts
    149 Views
    Jaime02J

    @abiabi
    Check this stack overflow post please
    https://stackoverflow.com/questions/65574567/rounded-corners-for-qmenu-in-pyqt

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Using nuitka to generate exe file

    Unsolved
    2
    0 Votes
    2 Posts
    68 Views
    jsulmJ

    @Mahdi_2020 You could simply use https://doc.qt.io/qt-6/resources.html

  • 0 Votes
    2 Posts
    41 Views
    JonBJ

    @AlexJMercer24K
    You do not show where you call handlePlot() from. Each time you call it it will call window.signal.connect(self.handleData) and that will create a new, additional connection to self.handleData. My guess is you call it more than once, so you end up with the signal connected multiple times to self.handleData.

    Either don't do that, count how many times you have done the connect or use the "unique connection" parameter to connect() (however you do that in Python) so that it does not create duplicate connections.

  • Dynamic Image Scaling Widget

    Unsolved
    5
    0 Votes
    5 Posts
    132 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
    72 Views
    F

    QGuiApplication is a bit smaller...

  • Avoid unnecessary repaints

    Unsolved
    2
    0 Votes
    2 Posts
    75 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
    106 Views
    G

    Thank you very much !

  • 0 Votes
    4 Posts
    112 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.

  • 0 Votes
    4 Posts
    124 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.

  • 0 Votes
    13 Posts
    285 Views
    T

    @Pl45m4

    Thanks for your explanation! I'll keep you posted if I find out something new on this topic.

  • 0 Votes
    3 Posts
    99 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.

  • 0 Votes
    1 Posts
    46 Views
    No one has replied
  • 0 Votes
    9 Posts
    235 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
    63 Views
    No one has replied
  • 0 Votes
    11 Posts
    312 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 to implement tabBar and tabButtons

    Unsolved
    1
    0 Votes
    1 Posts
    52 Views
    No one has replied