Skip to content
  • 0 Votes
    7 Posts
    703 Views
    SGaistS

    Did you try to run your application through gdb to learn where exactly it crashed ?

  • 0 Votes
    9 Posts
    2k Views
    mrjjM

    @ThePyGuy

    Hi
    Im not sure its possible as QMenu get all the events when open.

    https://forum.qt.io/topic/34557/solved-prevent-qmenu-from-being-modal

  • 0 Votes
    9 Posts
    1k Views
    jeremy_kJ

    @ben80 said in Use two QT5.x versions in parallel:

    @jeremy_k said in Use two QT5.x versions in parallel:

    What's the reason for using different versions of Qt 5? Going down this route opens up a class of problems involving incompatible intermingling.

    @jeremy_k said in Use two QT5.x versions in parallel:

    Option 4)
    Have you looked into using a virtualenv for the python program? Apt-get won't install into it, but pip will. This encapsulates the library path mangling, although the same environment pollution problem exists for child processes.

    It seems like there is so much that i can do wrong here. I am running this raspberry only at my home, so i am not distributing it. As long as i have a working solution (not too messy) it's ok for me.

    That's the best version of an unfortunate scenario. If you're careful about not executing other programs, the environment variable issue is manageable. Python modules that use external commands to discover bits of system configuration appears to be common. For example, https://github.com/pyinstaller/pyinstaller/issues/4657. QDesktopServices::openUrl() failing to work is another one to watch for.

    I cannot use pip on the raspberry, since there are no ARM packages for PySide2 provided. Therefore i am using apt-get. I am also using a pyenv virtualenv, but i need to copy the site-package files manually. Not nice, but it works.

    It might be reasonable to tell apt-get to install into the venv directory as an alternative root. For dpkg, the option appears to be --root=<alternative root>.

  • 0 Votes
    13 Posts
    6k Views
    SGaistS

    Try with:

    MAX_HEIGHT = 4096 # Arbitrary value class HeaderView(QHeaderView): def __init__(self, parent=None): super().__init__(Qt.Horizontal, parent=parent) self.setStyleSheet( "QHeaderView::section{background-color: #ffffff; " "font-weight: bold; " "padding-left: 2px; " "color: #3467ba; " "border:0px; " "border-left: 1px solid #ababab; " "border-bottom: 1px solid gray;}" ) self.setStretchLastSection(True) self.setDefaultAlignment(Qt.AlignCenter | Qt.Alignment(Qt.TextWordWrap)) def sectionSizeFromContents(self, logicalIndex): text = self.model().headerData(logicalIndex, self.orientation(), Qt.DisplayRole) alignment = self.defaultAlignment() metrics = QFontMetrics(self.fontMetrics()) width = metrics.boundingRect(QRect(), alignment, text).width() heights = [] for i in range(self.count()): text = self.model().headerData(i, self.orientation(), Qt.DisplayRole) size = self.sectionSize(i) rect = QRect(0, 0, size, MAX_HEIGHT) heights.append(metrics.boundingRect(rect, alignment, text).height()) height = sorted(heights)[-1] return QSize(width, height)
  • 0 Votes
    2 Posts
    2k Views
    F

    @raphasauer I have the same issue. Could you solve it?

  • 0 Votes
    6 Posts
    857 Views
    JonBJ

    @QueTeeHelper
    Exactly right, those are the comments I would have typed if it were my code :)

  • 0 Votes
    10 Posts
    966 Views
    D

    @kshegunov said in Odd issue, thread worker & timmer not running properly:

    Does the timer start at all? Does the thread start at all?

    the timer.start() gets called. But after that silence... Maybe everything gets deleted somewhere?

  • 1 Votes
    4 Posts
    3k Views
    S

    For anyone searching for the same thing. It is now possible with Qt for Python to create a QtDesigner plugin in Python:
    https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer

  • 0 Votes
    2 Posts
    1k Views
    LimeyLimeL

    It depends on how you create your project/file.
    If you create a project of the type Application "Qt for Python", you will end up with a main.py where PySide2 is imported and I could not find the template file in the Qt installation files.
    If you simply create a new file of the type Python | Python Class you will be offered to choose between PyQt5 and Pyside2. The template file is in your Qt installation folder: Qt\Tools\QtCreator\share\qtcreator\templates\wizards\classes\python.

    Sorry, QtCreator is great but not perfect for Python yet from what I can tell :-/

  • get rid of a button

    Unsolved Qt for Python
    4
    0 Votes
    4 Posts
    549 Views
    JonBJ

    @iwrwrc
    There are better ways of doing this than your approach. You have chosen to sacrifice the ability to re-edit the design at any future date. Up to you, it's not what I would have done.

    You have quoted

    QWidget(self)

    I don't know why, and my suggestion that the most likely might be an "unpositioned" widget declared like this but never added still remains. And of course it might have something to do with whatever you did to QTabWidget/QTabBar.

  • 0 Votes
    11 Posts
    3k Views
    P

    thank you each for your responses

    @SGaist said in QFormBuilder was unable to create a custom widget of the class 'QVideoWidget':

    What step did you use to create the original file that works with PyQt5 but not PySide2 ? Is it only a bug in Qt Creator or does it also fail at run time ?
    making a new project in qt-creator using python auto-generates the code for PyQt5, then i switched the imports to PySide2, and changed the uic method of loading UI for the QUiLoader method. everything else remains completely untouched, and 100% of everything else seems to be perfectly functional without producing any error the application will continue to run and function perfectly normal, but the widget won't appear. it's more of an 'ignore' than a 'fail'. from the bug report responses it seems maybe there just -isn't- a QVideoWidget for PySide2?

    @JonB said in QFormBuilder was unable to create a custom widget of the class 'QVideoWidget':

    you do not have to be able to put a widget on a Designer form or make it work with Promote to use it. Before you say you might abandon the whole Qt approach, are you aware that you can indeed create desired widget type at runtime even if you cannot see it/do so at design-time?

    i am aware, it's what i spoke of in this quote, though the way i worded it could have been more clear and could lead to confusion.

    @publicname40828 said in QFormBuilder was unable to create a custom widget of the class 'QVideoWidget':

    however, in the mean time i've figured out how to neatly embed QVideoWidget declared in python within an existing UI outside of qt creator

    i declared the QVideoWidget in python providing the ui as a parent (in arg), then used setGeometry to make it fit the exact location of the widget that was made in the form.ui. this is the only Widget that isn't working for me in the transition from PyQt5 to PySide2 so migrating the project will no longer be necessary, and being able to get the exact geometry in a glance in qt-creator made it a relatively quick fix

  • 0 Votes
    3 Posts
    927 Views
    R

    @Samuel-Bachorik I tried it, but I have the same problem, ehwn I try to execute the .exe file a message box open saying "Failed to execute script"

  • 0 Votes
    1 Posts
    316 Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    C

    Did you ever find a fix? Mine is doing the exact same thing.

  • 0 Votes
    2 Posts
    922 Views
    JonBJ

    @Haujet-Zhao
    I don't know whether it's "supposed" to work in PySide. PyQt5 is more robust/has more support for other libraries. Have a read anyway of the (only) reply to https://stackoverflow.com/questions/63502837/pyqt5-app-using-timer-to-run-a-function-with-a-loop-makes-it-freeze-up, as possible way forward for PySide2/6?

  • 0 Votes
    8 Posts
    2k Views
    JonBJ

    @anoop1
    As I said, how do you expect Python's Cmd.cmdloop to interact with Qt's event-driven system and windows/widgets?

  • 0 Votes
    2 Posts
    372 Views
    jsulmJ

    @Black-Cat You gorgot to connect the clicked signal from the new button...

  • 0 Votes
    5 Posts
    2k Views
    D

    @eyllanesc said in PySide2 & Threading... how to set data on widget from thread?:

    @Dariusz said in PySide2 & Threading... how to set data on widget from thread?:

    Do not implement the same logic in the same class so "manager" should only process the data and send it, then connect that signal to the GUI so that it updates the information. Class Worker(QObject): sendData = Signal(str) def process(self): value = "foo" self.sendData.emit(value) class GUI(QWidget): def apply_data(self, text): self.foo.setText(text) worker = Worker() thread = QThread() worker.moveToThread(thread) gui = GUI() worker.sendData.connect(gui.apply_data) QTimer.singleShot(0, worker.process) By default in the connection AutoConnection is used so since the sender lives in the second thread and the receiver in the main thread then QueuedConnection will be used.

    Hmmm thank you, but will this work with python Thread ? As the worker thread, I got is not Qt...

  • 0 Votes
    2 Posts
    748 Views
    JonBJ

    @john14
    QWidget::setDisabled(bool disable) or setEnabled(bool) are avialble to any QWidget, including a QDialog. If that is what you are wanting.