Skip to content
  • 0 Votes
    3 Posts
    405 Views
    J

    Hey @ndias,
    I am trying to attach to a QQuickWindow.
    After some more try & error I finally managed to get it working by using createWithInitialProperties like so:

    initialProperties = {"parent": window.contentItem()} object = component.createWithInitialProperties(initialProperties, engine.rootContext())
  • 0 Votes
    13 Posts
    3k Views
    J

    @JonB
    Yeah,I abandoned the monkey patching thing. It's not a good way to edit widgets.
    I'll follow your promote solution.I'll try google it.I didn't even know there is a promote feature before.
    I'm not a native english speaker,hope my codes and typos didn't make you angry.

    Really appreciate the help of yours.Thanks alot.

  • 1 Votes
    4 Posts
    840 Views
    SGaistS

    You should try to comment on the GItHub issue to see if you can get more details of how it was done ?

  • 0 Votes
    7 Posts
    785 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
    7k 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
    930 Views
    JonBJ

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

  • 0 Votes
    10 Posts
    1k 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
    592 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
    979 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
    342 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
    991 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?