Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. pyside2
    Log in to post

    • SOLVED How to cast c++ quintptr to QWidget in PySide2?
      Qt for Python • qt for python pyside2 • • Dariusz  

      2
      0
      Votes
      2
      Posts
      13
      Views

      Meh forgot about shiboken2 sigh shiboken2.wrapInstance(widget_pointer, QWidget) To the rescue!
    • SOLVED Getting started with PySide. I have a specific panel I want to create. Looking good starter content.
      Qt for Python • pyside2 • • probiner  

      8
      0
      Votes
      8
      Posts
      136
      Views

      @probiner Wrong, you will be able to use QSortFilterProxyModel against QStandardItemModel. What I pointed out was: QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) means that it can act as a proxy on any QAbstractItemModel. The docs tell you that QStandardItemModel inherits QAbstractItemModel. Therefore QSFPM can accept QSIM as its source model. And if it some point you derive your own model class from QAbstractItemModel the proxy will work against that for the same reason. This is what inheritance means in C++ and in Python.
    • UNSOLVED Build PySide2 5.15.5 with --debug fails with access violation or assert
      Qt for Python • pyside2 • • loopless  

      4
      0
      Votes
      4
      Posts
      118
      Views

      Hi again loopless, sorry for getting back to you so late. I'm actually struggling myself to build PySide 2 on Windows (running into different problems, though) so trying to reproduce this has been challenging. In the meantime, may I suggest that you a) try with a newer Qt version like 5.15.10 b) try with a newer Python version like Python 3.10 and see what happens?
    • UNSOLVED opencv cameras into qml using python and pyside2
      Qt for Python • python pyside2 • • m.reza  

      9
      0
      Votes
      9
      Posts
      233
      Views

      @SGaist i did, it runs smooth with one camera, since its using available picture to stream, problem is when we have more than one camera, i cant choose each stream directly to communicate with in Qt. lets say i have a class in python that each def() does one job with a camera, one for focusing on for taking a picture one for sending too AI model and so on, i need to make 6 different object from this class for 6 different cameras and connect them to buttons in Qml, what i explained is alright, but the only part i can not do is the live stream for each camera separately, there is no function or at least i couldn't find which define separate stream of images for separate windows in qml, there are two method so far which looks for available stream of image not a specific one, one is imageprovider, other is paintclass this is were i have the main problem
    • SOLVED shiboken2 compiles
      Qt for Python • python qt for python pyside2 • • wwms  

      2
      0
      Votes
      2
      Posts
      99
      Views

      Hi and welcome to devnet, You do not have a constructor without argument.
    • UNSOLVED How to deploy QML with PyInstaller?
      Qt for Python • qt for python pyside2 • • Curtwagner1984  

      2
      0
      Votes
      2
      Posts
      164
      Views

      OK, after more searching I found this answer form the same helpful author. He says that when the qml files aren't in the root folder you should add import "qrc:/QML in the main file so it could see other components in the qrc file. (This path is specfic to my case because my qml files are in ./qml folder.) On thing to note that might seem obvious but I spent quite a few tries to figure it out is that you must compile the qrc file to py after every change you make to the qml files. Meaning running pyside2-rcc qml.qrc -o qml_rc.py. Otherwise the imports won't update, and you'll be stuck trying to figure out why the changes you're making don't affect anything.
    • SOLVED strange behaviour in hight DPI resolution
      Qt for Python • pyside2 • • Fakhreddine  

      12
      0
      Votes
      12
      Posts
      251
      Views

      @SGaist ok merci :)
    • SOLVED PySide 6: GUI Freezing even when using QThreadPool class
      Qt for Python • python qt for python pyside2 pyside • • ccortez  

      4
      0
      Votes
      4
      Posts
      275
      Views

      So the one that creates a file is working but the one that changes a GUI element freezes ? Do I get you correctly ?
    • UNSOLVED Accessing text field and processing in python
      Qt for Python • python qt for python pyside2 pyside • • aayushlakkad  

      1
      0
      Votes
      1
      Posts
      174
      Views

      No one has replied

    • UNSOLVED change tick labels
      Qt for Python • python qt for python pyside2 pyside • • aayushlakkad  

      3
      0
      Votes
      3
      Posts
      130
      Views

      @CristianMaureira please find link to my plotting code link .
    • SOLVED Resetting a PySide6 Window after closing it
      Qt for Python • python qt for python pyside2 pyside • • ccortez  

      3
      0
      Votes
      3
      Posts
      433
      Views

      @JonB Thank you for this, it helped me solve my issues!
    • SOLVED Plotting with python
      Qt for Python • python qt for python pyside2 pyside • • aayushlakkad  

      8
      0
      Votes
      8
      Posts
      274
      Views

      This is a different issue that should have it's own thread as it's not related to the problem at hand. You should also mark this thread as solved.
    • UNSOLVED How to set row color in tableview with qsqltablemodel ?
      Qt for Python • python qt for python pyside2 pyside • • Cedric.Niu  

      5
      0
      Votes
      5
      Posts
      307
      Views

      @CristianMaureira @JonB Sorry... I mean
    • UNSOLVED PySide find out last clicked QLineEdit
      Qt for Python • python qt for python pyside2 pyside • • To RGB  

      5
      0
      Votes
      5
      Posts
      316
      Views

      @JonB argh! I spend a whole day yesterday to figure out how to make it work, and all I needed to do is to write mySignal=Signal() not in the init, but in the class body! Jeeeez. Thanks a lot! Your advices and link helped!
    • UNSOLVED QDirIterator not working with flags ;/
      Qt for Python • pyside2 • • Dariusz  

      4
      0
      Votes
      4
      Posts
      194
      Views

      @Dariusz Filters are flags so if you want to get directories and not dotanddots then use: it = QDirIterator( dirPath, QDir.Dirs | QDir.NoDotAndDotDot, flags=QDirIterator.Subdirectories ) If you want files: it = QDirIterator( dirPath, QDir.Files | QDir.NoDotAndDotDot, flags=QDirIterator.Subdirectories ) Same: it = QDirIterator( dirPath, ["*.exr"], filters=QDir.Files | QDir.NoDotAndDotDot, flags=QDirIterator.NoIteratorFlags )
    • UNSOLVED Hover stylesheet. PySide2
      Qt for Python • pyside2 • • Caeden  

      3
      0
      Votes
      3
      Posts
      189
      Views

      Okay thanks, I will try it
    • SOLVED How can I properly implement QSortFilterProxyModel.parent() to handle a virtual column?
      Qt for Python • python qt for python pyside2 • • Unai  

      4
      0
      Votes
      4
      Posts
      231
      Views

      Thanks @SGaist! I just got a solution on StackOverflow, so I’m marking this as solved, but it’s always great to see how the pros do it, so I’m definitely reading about KExtraColumnsProxyModel too 😊
    • SOLVED Attach QMLComponent to QQuickWindow in PySide2
      QML and Qt Quick • qml pyside2 parent qqmlengine • • J0Nes  

      3
      0
      Votes
      3
      Posts
      159
      Views

      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())
    • SOLVED How to override PySide2 widget's method generated by Qt Designer?
      Qt for Python • qt for python pyside2 • • johnjml  

      13
      0
      Votes
      13
      Posts
      1200
      Views

      @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.
    • UNSOLVED Use GammaRay with PyQt / PySide
      Tools • python pyside2 pyqt5 gammaray • • Name already in use  

      4
      1
      Votes
      4
      Posts
      297
      Views

      You should try to comment on the GItHub issue to see if you can get more details of how it was done ?
    • UNSOLVED Using signal/slot transfer data from sub thread to main thread,however,the applicaiton always crash!:(
      Qt for Python • pyside2 • • jowei  

      7
      0
      Votes
      7
      Posts
      336
      Views

      Did you try to run your application through gdb to learn where exactly it crashed ?
    • UNSOLVED How to transfer mouse focus back while showing a QMenu?
      General and Desktop • pyside2 qmenu focus • • ThePyGuy  

      9
      0
      Votes
      9
      Posts
      653
      Views

      @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
    • SOLVED Use two QT5.x versions in parallel
      Installation and Deployment • qt5 pyside2 cross-compile raspberry pi 2 • • ben80  

      9
      0
      Votes
      9
      Posts
      387
      Views

      @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>.
    • UNSOLVED How to make QTableView to adjust the height of it's horizontal header automatically in PyQt?
      Qt for Python • qt for python pyside2 • • ThePyGuy  

      13
      0
      Votes
      13
      Posts
      2688
      Views

      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)
    • UNSOLVED Error: 'Failed to extract plugin meta data'
      QML and Qt Quick • qml qtquick pyside2 raspberrypi • • raphasauer  

      2
      0
      Votes
      2
      Posts
      1023
      Views

      @raphasauer I have the same issue. Could you solve it?
    • SOLVED QStandardItemModel custom sorting rules
      Qt for Python • python pyside2 • • QueTeeHelper  

      6
      0
      Votes
      6
      Posts
      401
      Views

      @QueTeeHelper Exactly right, those are the comments I would have typed if it were my code :)
    • UNSOLVED Odd issue, thread worker & timmer not running properly
      Qt for Python • python pyside2 • • Dariusz  

      10
      0
      Votes
      10
      Posts
      545
      Views

      @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?
    • UNSOLVED How to create custom widget plugin for Qt Designer with Qt for Python?
      Qt for Python • qt for python pyside2 • • StarterKit  

      4
      0
      Votes
      4
      Posts
      1156
      Views

      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
    • UNSOLVED Switching PySide2 to PyQt5 in Qt Creator
      Qt for Python • python qt for python pyside2 • • hendry33  

      2
      0
      Votes
      2
      Posts
      395
      Views

      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 :-/
    • UNSOLVED get rid of a button
      Qt for Python • qt for python pyside2 • • iwrwrc  

      4
      0
      Votes
      4
      Posts
      308
      Views

      @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.
    • UNSOLVED QFormBuilder was unable to create a custom widget of the class 'QVideoWidget'
      Qt for Python • qt for python pyside2 • • publicname40828  

      11
      0
      Votes
      11
      Posts
      1341
      Views

      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
    • Problem creating an .exe file
      Qt for Python • python qt for python pyside2 pyside • • RafaelRS  

      3
      0
      Votes
      3
      Posts
      521
      Views

      @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"
    • UNSOLVED How to split project based on .pyproject file into sub modules?
      Qt for Python • qt for python pyside2 • • Borys  

      1
      0
      Votes
      1
      Posts
      192
      Views

      No one has replied

    • UNSOLVED Error (The specified module could not be found / plugin cannot be loaded for module "QtQuick")
      Qt for Python • python qt for python pyside2 pyside • • Ryuyxx  

      2
      0
      Votes
      2
      Posts
      718
      Views

      Did you ever find a fix? Mine is doing the exact same thing.
    • UNSOLVED PySide2 and PySide6 freezes when a QThread contains a PyAudio() stream, while PyQt5 works well. Is that a bug or I had the wrong usage?
      Qt for Python • python qt for python pyside2 • • Haujet Zhao  

      2
      0
      Votes
      2
      Posts
      520
      Views

      @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?
    • UNSOLVED Running multiple plots with pyside2
      Qt for Python • python qt for python pyside2 pyside • • anoop1  

      8
      0
      Votes
      8
      Posts
      944
      Views

      @anoop1 As I said, how do you expect Python's Cmd.cmdloop to interact with Qt's event-driven system and windows/widgets?
    • SOLVED QCommandLinkButton stops working when I recreate it
      Qt for Python • python qt for python pyside2 • • Black Cat  

      2
      0
      Votes
      2
      Posts
      183
      Views

      @Black-Cat You gorgot to connect the clicked signal from the new button...
    • UNSOLVED PySide2 & Threading... how to set data on widget from thread?
      General and Desktop • pyside2 thread • • Dariusz  

      5
      0
      Votes
      5
      Posts
      1297
      Views

      @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...