Skip to content

Qt for Python

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

3.2k Topics 14.1k Posts
  • 0 Votes
    1 Posts
    17 Views
    No one has replied
  • 0 Votes
    9 Posts
    133 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
    39 Views
    No one has replied
  • 0 Votes
    11 Posts
    234 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
    32 Views
    No one has replied
  • How can I add other widgets by pressing a button on PyQt5?

    Unsolved
    6
    0 Votes
    6 Posts
    185 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

  • 0 Votes
    7 Posts
    234 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
    119 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.

  • 0 Votes
    6 Posts
    91 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
    2k 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
    91 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
    94 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

  • 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
    774 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
    229 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
    184 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.

  • pyside6-deploy - QtMultimedia

    Solved
    4
    0 Votes
    4 Posts
    137 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.