Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • 0 Votes
    7 Posts
    2k Views
    @eyllanesc Thank you for pointing me an example, I will be more patient in searching through the documentation of Qt although I must admit that it's not that easy to find what you need at a first glance. According to the community helpfulness, that is why I have raised my question here, expecting a help which I already got it thanks to you guys.
  • force use of alsa when using QSound

    Unsolved 10 Apr 2021, 22:02
    0 Votes
    1 Posts
    396 Views
    No one has replied
  • QGradient.stops is not available on Pyside6/PyQt6

    Solved 9 Apr 2021, 14:20
    0 Votes
    4 Posts
    387 Views
  • PySide6

    Unsolved 30 Mar 2021, 06:12
    0 Votes
    5 Posts
    2k Views
    Another difference between the PyQt6 and Pyside6 is the way this libraries loads .ui files generated from Qt Designer and the scripts used to convert .ui files to Python code. You can find more detailed information on https://www.learnpyqt.com/blog/pyqt6-vs-pyside6/ page.
  • Crash in simple PyQt5 app

    Solved 8 Apr 2021, 07:50
    0 Votes
    5 Posts
    2k Views
    ok, at first glance i fixed the crash, now app destroys objects correctly class ListWidgetCompleter(QObject): def __init__(self, popup: QWidget, widget: QWidget): QObject.__init__(self, None) assert popup != None assert widget != None self.destroyed.connect(ListWidgetCompleterDestroed) # assert isinstance(parent, QLineEdit) self.__maxVisibaleItems = 0 self.__attachPoupToWidget(popup, widget) def __del__(self): print("<<>> ListWidgetCompleter py layer deleted") def __attachPoupToWidget(self, popup: QWidget, widget: QWidget): self.__popup = popup self.__widget = widget self.__popup.setParent(None) self.__popup.setWindowFlag(Qt.Popup) self.__popup.installEventFilter(self) self.__widget.installEventFilter(self) self.__popup.setFocusProxy(self.__widget) self.__popup.setFocusPolicy(self.__widget.focusPolicy()) def setMaxVisibleItems(self, maxItems: int): self.__maxVisibaleItems = maxItems def popup(self): return self.__popup def widget(self): return self.__widget def showPopup(self, rect): pos = self.__widget.mapToGlobal(QPoint(0, 0)) print("X " + str(pos.x()) + " Y " + str(pos.y()) + " le.w " + str(self.__widget.width())) self.__popup.setGeometry(pos.x(), pos.y() + self.__widget.height(), self.__widget.width(), 80) if not self.__popup.isVisible(): self.__popup.show() self.__popup.setFocus() def eventFilter(self, o: QObject, e: QEvent): if self.__widget == o: pass else: if e.type() == QEvent.KeyPress: print("keypress") self.__widget.setFocus() self.__widget.event(e) return False return QObject.eventFilter(self, o, e) <<>> DicView py layer deleted <<>> ListWidgetCompleter py layer deleted <<>> ListWidgetCompleter C++ obj removed<PyQt5.QtCore.QObject object at 0x000002345A1C88B0> <<>> SuggestionPopup py layer deleted <<>> SuggestionPopup C++ obj removed<PyQt5.QtWidgets.QWidget object at 0x000002345A1C88B0> <<>> DicView C++ obj removed<PyQt5.QtWidgets.QWidget object at 0x000002345A194EE0>
  • 0 Votes
    27 Posts
    3k Views
    So my shape from the txt file (annotation file) is : shapes from the file: [('Object_A', [(14, 134), (816, 134), (816, 458), (14, 458)], None, None, False)] Then in the file canvas.py a function is written for moveMouseEvent() which includes the panning of the shape, moving of the shape and is as follows: if Qt.LeftButton & ev.buttons(): if self.selectedVertex(): self.boundedMoveVertex(pos) self.shapeMoved.emit() self.repaint() elif self.selectedShape and self.prevPoint: self.overrideCursor(CURSOR_MOVE) self.boundedMoveShape(self.selectedShape, pos) self.shapeMoved.emit() self.repaint() print(f'selected shape prev point: {self.selectedShape.points}') I added the print statement just to output the coordinates of the shape when moved and the output is as follows: selected shape prev point: [PyQt5.QtCore.QPointF(14.0, 133.0), PyQt5.QtCore.QPointF(816.0, 133.0), PyQt5.QtCore.QPointF(816.0, 457.0), PyQt5.QtCore.QPointF(14.0, 457.0)] selected shape prev point: [PyQt5.QtCore.QPointF(17.0, 131.0), PyQt5.QtCore.QPointF(819.0, 131.0), PyQt5.QtCore.QPointF(819.0, 455.0), PyQt5.QtCore.QPointF(17.0, 455.0)] selected shape prev point: [PyQt5.QtCore.QPointF(23.0, 131.0), PyQt5.QtCore.QPointF(825.0, 131.0), PyQt5.QtCore.QPointF(825.0, 455.0), PyQt5.QtCore.QPointF(23.0, 455.0)] selected shape prev point: [PyQt5.QtCore.QPointF(33.0, 131.0), PyQt5.QtCore.QPointF(835.0, 131.0), PyQt5.QtCore.QPointF(835.0, 455.0), PyQt5.QtCore.QPointF(33.0, 455.0)] I am trying to save all these points in a concatenated list and then just use the last list of QPointF to compare with the shapes from the file. To compare I want to convert QPointF points as shown above in a list like [[(1, 2), (3, 4), (5, 6), (7, 8)], [(9, 10), (11, 12), (13, 14), (15, 16)]] . I can do this part but how do I convert the QPointF to list of lists and where can I access these points in the file labelImg.py?
  • How do I get coordinates of painted area ?

    Unsolved 7 Apr 2021, 11:58
    0 Votes
    1 Posts
    212 Views
    No one has replied
  • qss url() not working on Python 3.9

    Solved 5 Apr 2021, 17:12
    0 Votes
    8 Posts
    1k Views
    @eyllanesc png works in both versions. with svg, using set QT_DEBUG_PLUGINS=1 python3.9 my_file.py when checking the box it fails with "Cannot load library [...]\\Roaming\\Python\\Python39\\site-packages\\PySide6\\plugins\\imageformats\\qsvg.dll: Das angegebene Modul wurde nicht gefunden. [cannot find the module]" besides other similar errors (even though it exists). When I run it with Python3.8 it works. However, I noticed that PySide2/6 (and weirdly I think also the Python 3.9 installation) was located in Roaming for Python 3.9 and that it seems to look in various places for packages and the paths for site-packages in Roaming differ from the paths in AppData/Local/Programs. Therefore, although there was only one global (PATH) Python 3.9 installed, I tried by removing the Roaming stuff and reinstalled Python 3.9 and the packages, and now it seems to work...
  • 0 Votes
    2 Posts
    787 Views
    Hi and welcome to devnet, Do you mean you want a button or a text like a hyperlink ?
  • QGridLayout in PyQt5

    Unsolved 3 Apr 2021, 03:52
    0 Votes
    2 Posts
    256 Views
    Whats the content of form.ui ?
  • QMessageBox freezes gui

    Unsolved 6 Apr 2021, 14:47
    0 Votes
    2 Posts
    538 Views
    @iomh Please provide a minimum verifiable example
  • 0 Votes
    1 Posts
    169 Views
    No one has replied
  • 0 Votes
    5 Posts
    1k Views
    @midnightdim Yes, this is the correct way to compare sizes or dates. You may assume Qt infrastructure will only call lessThan() with source_left.column() == source_right.column(). You can put in an assert source_left.column() == source_right.column() to verify.
  • PySide 6.0.3 not in pip yet

    Unsolved 5 Apr 2021, 21:17
    0 Votes
    1 Posts
    187 Views
    No one has replied
  • 0 Votes
    2 Posts
    281 Views
    Hi and welcome to devnet, Are you looking for the currentChanged signal of your view's selection model ?
  • Set Position for Label inside QTab not Working

    Unsolved 2 Apr 2021, 12:21
    0 Votes
    2 Posts
    2k Views
    @philipsj33 You would not normally use any absolute positioning coordinates for widgets. It's not a good idea. Rather you would use Qt's QLayouts, as just about all widgets examples will do. have you started by reading https://doc.qt.io/qt-5/layout.html ?
  • 0 Votes
    11 Posts
    2k Views
    Also I'm having trouble inserting the QTextFrame without it putting a newline in my QTextEdit. I don't know how to make it do that. The funny thing is it puts one before the QTextFrame but not one after it. Here's my code: def addmsg(textedit, nick, message): if config.show_timestamp: obj_now = datetime.now() textedit.insertPlainText(f"[{obj_now.hour: >2}:{obj_now.minute: >2}] ") textedit.cursor.insertText("<") nickframe = textedit.cursor.insertFrame(QTextFrameFormat()) nickframe.nick = nick framecursor = nickframe.firstCursorPosition() framecursor.insertText(nick) textedit.cursor.insertText("> ") colorify(textedit, message) textedit.cursor.insertHtml("<br>") Here's how it looks: < inhahe_> test
  • crashing on accessing 'self' in the slots

    Solved 21 Nov 2018, 10:05
    0 Votes
    3 Posts
    1k Views
    You have created the button variable without the "self." and you try to using it with the "self." you have to change this line: button = QPushButton('PyQt5 button', self) with this: self.button = QPushButton('PyQt5 button', self) and then you can access it with: self.button.move(400,250)
  • Qt Creator

    Unsolved 31 Mar 2021, 10:38
    0 Votes
    2 Posts
    260 Views
    @DiGol have you started by reading https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html ?
  • deleting and redraw new buttons

    Solved 26 Mar 2021, 01:36
    0 Votes
    5 Posts
    585 Views
    yes , i've done all i can, and finally it's ok. and the problems seem to be in the widget where i put my buttons. all was create correctly but nothing was visible. i 've changed the kind of widget i use, and now it's ok. (i need to say that not is clear in my mind about how qt is working.) thanks for all @jsulm