Skip to content

Qt for Python

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

3.3k Topics 14.5k Posts
  • 0 Votes
    2 Posts
    222 Views
    S
    Answering my own question for future reference. Workarounds I have tried that do not work: self.setMouseGrabEnabled(False) self.setKeyboardGrabEnabled(False) self.parent().setFocus() event.setAccepted(False) The hacky workaround that solved my issue is this. def mouseReleaseEvent(self, event): super(SceneWindow, self).mouseReleaseEvent(event) e = QMouseEvent(QEvent.MouseButtonRelease, QPoint(-1,-1), Qt.LeftButton, Qt.NoButton, Qt.NoModifier ) QApplication.postEvent(self.parent(), e) If anyone has a better workaround please feel free to share. Thanks :)
  • Change button pressed color without adding a border to the button

    Moved Unsolved
    4
    0 Votes
    4 Posts
    522 Views
    SGaistS
    Can you provide a minimal complete example to check what is happening ?
  • Playing RTSP URL with QMediaPlayer

    Unsolved
    3
    0 Votes
    3 Posts
    1k Views
    G
    @Lahearle Hi! I did manage to achieve this by using OpenCV, but since I have to do a conversion to embed in Qt, it does takes some CPU. By the way, I used to stream webcams (connected to USB) in the past with Qt, by using Phonon in that era (with PyQt5). A webcam also have a indefinite amount of time. But the problem here is not that. The problem is that I need to set TCP transport for RTSP (I already exposed that the same happens in FFmpeg if I do no set TCP as transport). So, the behavior in Qt or FFmpeg is the same (which the difference that with FFmpeg I can set TCP transport). So I think this has nothing to do with "indefinite stream time". As a side note, when using FFmpeg command line directly (without setting TCP transport), I got the same output as with Qt... So.
  • Qt for Python compilation question

    Unsolved
    3
    0 Votes
    3 Posts
    337 Views
    F
    PySide6 provides a deployment tool based on Nuitka (see https://doc.qt.io/qtforpython-6/deployment/index.html#deployment-guides ).
  • Pyside6 support on Raspberry OS

    Unsolved
    3
    0 Votes
    3 Posts
    652 Views
    F
    aarch64 wheels should now be available ( https://bugreports.qt.io/browse/PYSIDE-2375 ), also have you tried cross-building yourself ( https://doc.qt.io/qtforpython-6/gettingstarted/index.html#cross-compilation )?
  • Python Decorators: Custom Logging for Function Calls

    Unsolved
    3
    0 Votes
    3 Posts
    351 Views
    SGaistS
    Hi, This article contains exactly what you are looking for.
  • Segment fault when opening Dialog from a different QThread

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    S
    @jeremy_k said in Segment fault when opening Dialog from a different QThread: Qt::ConnectionType is the third argument of ~ half of the overloads of QMetaObject::invokeMethod, going back to at least Qt 4.5.1. I didn't know that! Looks like I should change the implementation then...
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Stop thread that's running a while loop

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    S
    while self.running: would at least work inside C++. Python has additional quirks due to the Global Interpreter Lock. I don't use Python and thus don't know the details. As you have figured out isInterruptionRequested is a method of QThread. QThread also has a class method (in C++, don't know how this translates to Python) currentThread() to get the thread of the context of your code. So, in C++ it would look like this: while(!QThread::currentThread().isInterruptionRequested()) ....
  • QTabWidget.geometry().height() gives me negative value

    Unsolved
    8
    0 Votes
    8 Posts
    582 Views
    SGaistS
    Why are you making widgets with that kind of height ? A QTableWidget already manages big amount of rows and columns.
  • have a fix header line in QscrollArea

    Unsolved
    5
    0 Votes
    5 Posts
    489 Views
    JonBJ
    @otaolafr I just found that QAbstractScrollArea (and hence QScrollArea) might have what you want. https://doc.qt.io/qt-6/qabstractscrollarea.html#details It is possible to reserve a margin area around the viewport, see setViewportMargins(). The feature is mostly used to place a QHeaderView widget above or beside the scrolling area. Subclasses of QAbstractScrollArea should implement margins.
  • Python List Comprehension Error: Unexpected Output

    Unsolved qt for python
    2
    0 Votes
    2 Posts
    478 Views
    JonBJ
    @Sachin-Bhatt Not that a Qt Python forum is the best for general Python questions, but: It correctly prints [0, 4, 16, 36, 64]. I suggest you re-examine whatever you claim to be doing. Start by inserting print(even_numbers), you know that squared_values will have the same number of elements as that.
  • How to import c++ qml plugin to python project?

    Unsolved
    8
    0 Votes
    8 Posts
    615 Views
    K
    I tried to load this plugin by QQmlApplicationEngine::addPluginPath, which is the way I load successfully in C++. But it still shows Unable to load library C:\Users\ASUS\Documents\Qt Project\cv-tools\3rdparty\KmcUI\bin\kmcuiplugin.dll: The specified program could not be found. But I'm pretty sure there exists such a dll.
  • JSONDecoderError during run empty pyproject

    Solved
    3
    0 Votes
    3 Posts
    297 Views
    K
    @friedemannkleint said in JSONDecoderError during run empty pyproject: Have you checked the file; was maybe an UTF8-BOM added or sth similarly weird? Yes, BOM caused such a disaster
  • How to build a QIODevice from Python IO object

    Unsolved
    2
    0 Votes
    2 Posts
    275 Views
    SGaistS
    Hi, One starting point is to create a QIODevice subclass that has a RawIO object as class member and then re-implement the writeData method to write into that object. Hope it helps
  • How to pass signals between parallel widgets?

    Unsolved
    2
    0 Votes
    2 Posts
    279 Views
    JonBJ
    @delipizen Not sure I understand, but will try. Two things. First, you don't/don't think of it as "send" signals from something to something. Rather, something sends a signal without any idea of anything in the outside world, so it never sends "to" anything; and things in the outside world subscribe and listen to the signal being emitted. Second, signals are not connected/sent between classes, they are connected/sent through instances of classes. So you can only connect a signal from an instance of class AAAA to an instance of class B. And the only instance of class B you create is the self.b = B(). So that has to be visible when you do the connect(). Given your code you would need something like: a = A() a.aa.aaa.aaaa.sig.connect(a.b.slot) If you don't want to reference the a instance, how else will you access (a) the a.aa.aaa.aaaa instance to connect its sig signal and (b) the a.b instance to connect its slot slot? If you can arrange for that (e.g. perhaps passing them around as parameters) then you could connect them that way. Also, if it helps, you can define separate signals in multiple classes and "chain" connections to connect signals to slots, including chaining signals to signals. So for example, if you defined suitable extra signals, you could have something like: a.aa.sigAA.connect(a.aa.aaa.sigAAA.connect(a.aa.aaa.aaaa.sig.connect(a.b.slot))) [EDIT: Looking at above, I don't quite mean this one line of code! I mean connect each one's signal to emit a signal to fire the next one directly.] You don't have to do that in one statement as shown here: you could connect instances at each level as you go, e.g. class AAA.__init__() could do the connection level to the self.aaaa = AAAA() it creates, so the top-level a which can access the a.b.slot method does not need to know all the way down to a.aa.aaa.aaaa.sig.connect, it can just do some a.aa.sigAA.connect(). Don't know whether the above helps. Depends what you are trying to do.
  • Changes various values in self.model (in TableView) to gain dat to sql query

    Unsolved
    3
    0 Votes
    3 Posts
    265 Views
    Karoluss96K
    @JonB Look intersting I'll respond if I still next problem appears.
  • QSlider groove color

    Solved
    3
    0 Votes
    3 Posts
    1k Views
    C
    @SGaist I found a solution for my case. The hint someone pointed to (on another board) was to set all the styles. The code below achieves what I was after with the original shown to the side (might not be the most elegant code) . Relevant links are: https://stackoverflow.com/questions/76962373/pyqt6-qslider-how-to-set-groove-color (see comment "With complex widgets such as QComboBox and QScrollBar, if one property or sub-control is customized, all the other properties or sub-controls must be customized as well." .. usability issue with that requirement I'd say!) https://het.as.utexas.edu/HET/Software/html/stylesheet-examples.html#customizing-qslider import sys from PyQt6 import QtWidgets, QtCore class MainWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.setFixedWidth(400) self.setFixedHeight(400) frame = QtWidgets.QFrame() layout = QtWidgets.QHBoxLayout() frame.setLayout(layout) slider1 = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical) slider1.setFixedHeight(300) slider1.setFixedWidth(20) slider1.setMinimum(0) slider1.setMaximum(100) slider1.setValue(50) slider2 = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical) styles = "QSlider::groove:vertical { background: white; position: absolute; left: 8px; right: 7px; }" styles += "QSlider::handle:vertical { height: 11px; background: #979EA8; margin: 0 -4px; border-style:solid; border-color: grey;border-width:1px;border-radius:3px}" styles += "QSlider::sub-page:vertical { background: #979EA8; border-style:solid; border-color: grey;border-width:1px;border-radius:2px}" styles += "QSlider::add-page:vertical { background: #979EA8; border-style:solid; border-color: grey;border-width:1px;border-radius:2px}" slider2.setStyleSheet(styles) slider2.setFixedHeight(300) slider2.setFixedWidth(20) slider2.setMinimum(0) slider2.setMaximum(100) slider2.setValue(50) layout.addWidget(slider1) layout.addWidget(slider2) layout.addStretch(True) self.layout().addWidget(frame) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) ex = MainWindow() ex.show() sys.exit(app.exec())
  • why are several of my pyside6 modules not working?

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    I
    @SGaist I am not using a virtual environment. When I look at the imports in VSCode, they look fine. But when I run the program, it gives me the error. I am using python 3.11.4. I downloaded and ran this program: https://doc.qt.io/qtforpython-6/examples/example_datavisualization_bars3d.html [image: 53ff31f7-3df9-4a5a-bdca-0b0e3353d601.png]
  • How to integrate qmllint with PySide6 development?

    Unsolved
    4
    0 Votes
    4 Posts
    862 Views
    A
    @EddieC I found this issue covering the topic. Maybe already possible but undocumented https://bugreports.qt.io/browse/PYSIDE-2210