Skip to content

Qt for Python

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

3.3k Topics 14.4k Posts
QtWS25 Last Chance
  • Can't read from the standard input

    Solved
    8
    0 Votes
    8 Posts
    337 Views
    A

    @JonB
    Thanks for help. I experimented with sys.stdin.read(5) and it works. The data doesn't have to be binary, I can convert it, so using QTextStream, adding a trailing newline character and receiving with sys.stdin.readline() works as well.

  • Click-through window will blink due setWindowFlags

    Unsolved
    3
    0 Votes
    3 Posts
    529 Views
    L

    I run into the same issue. Except I am using Pyside2. Is there any way to fix this issue? Calling update hides the window. So after setWindowFlags function, I have to call show function but like OP it flickers. Not sure why this sort of design is implemented. Can this be remedied in a future version or is there a workaround? My code is like this:

    def setPassThroughMode(window, enable): if enable: # Set the window to be transparent for input window.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowTransparentForInput) else: # Restore the normal floating window behavior window.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.FramelessWindowHint) window.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents, enable) window.setAttribute(QtCore.Qt.WA_NoMousePropagation, enable) # Ensure changes take effect window.show() # Reapply visibility to update flags def togglePassThroughMode(window): # Check if the window is valid if not shiboken2.isValid(window): return # Check if the window is in pass-through mode isPassThrough = isPassThroughEnabled(window) # Toggle the state using setPassThroughMode setPassThroughMode(window, not isPassThrough) # To turn it off, you have to call the function twice if isPassThrough: setPassThroughMode(window, not isPassThrough)

    I have to call it twice to turn these flags off also, not sure why that is.

  • QtAsyncIO conflict with QDialog.exec()

    Unsolved
    2
    0 Votes
    2 Posts
    201 Views
    SGaistS

    Hi and welcome to devnet,

    I haven't used that module yet however I think that manually triggering a secondary event loop like that is wrong.

    I just found this example which confirms my intuition.

  • Pyqt Signals connecting multiple slots

    Unsolved
    6
    0 Votes
    6 Posts
    454 Views
    JonBJ

    @Dwarrel said in Pyqt Signals connecting multiple slots:

    My assumption was indeed that the emit would be independent of the execution time of a listener (connected function). Knowing that that is not the case completely explains the observed behaviour.

    OIC!

    The behaviour depends on the parameters to connect() and whether the signalling object and the slot object are in the same or different threads.

    Assuming default --- no extra parameter to connect() ---

    If they are in the same thread signal/slot is executed directly, upon emit signal call, i.e. it behaves just like a direct call to the slot(s). Slots are executed consecutively per the order they were connect()ed. Signaller code does not continue until all slots have completed. If they are in different threads signal causes slot(s) to be executed queued. When slot object thread next enters Qt event loop slot(s) get executed. Order is actually undetermined. Signaller code continues immediately after emit, it does not wait. Extra parameter to connect() can be used to alter default behaviour, see docs. You still should not try DirectConnection across threads, you could choose QueuedConnection if same thread. But non-default is unusual, unless you know what you are doing.

    P.S.
    I just noticed you are Python. the above is still correct, but there can be extra restrictions with multiple threads to do with Python GIL. But nothing special if all same thread.

  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    31 Views
  • 1 Votes
    8 Posts
    524 Views
    F

    As it is an issue of the underlying Qt library unrelated to the Python bindings it would have to reported under QTBUG though ( see https://wiki.qt.io/Reporting_Bugs / https://wiki.qt.io/Qt_for_Python/Reporting_Bugs ).

  • How to set QCamera resolution on Qt 6

    Solved
    4
    0 Votes
    4 Posts
    372 Views
    R

    @friedemannkleint Thx

  • QTableWidgetItem - type

    Solved
    4
    0 Votes
    4 Posts
    591 Views
    MasterQM

    OK, I found my mistake.

    It is not because of locale.string_format. Two of the columns are to separated positive and negative values. One is holding all positives and the other all negativs.

    If a positive value is found I created a QTableWidgetItem for the 'positive' column but forgott the create one for the 'negative' column and vice versa.

    Stupid!

  • LocalStorage in QWebEngineView not saved after running.

    Unsolved
    2
    0 Votes
    2 Posts
    176 Views
    JonBJ

    @Daic
    I don't know, but start by verifying

    Setting attribute QWebEngineSettings::LocalStorageEnabled is true. QWebEngineProfile::persistentStoragePath() is set to where you expect, does it get updated?
  • QTableView - CheckState

    Solved
    5
    0 Votes
    5 Posts
    268 Views
    MasterQM

    Yes, you are right. PartiallyChecked is the right key word here.

    Now I see, what the difference was between my C++ version and the Python version.

    @JonB said in QTableView - CheckState:

    If you are using 1, True or an expression returning true for Qt.CheckState.Checked that is wrong, and would set Qt.CheckState.PartiallyChecked.

    That was the point.

    thnx

  • 0 Votes
    14 Posts
    1k Views
    JoeCFDJ

    @Big_bo libqwebp.so needs libwebp.so.6. Type command:
    locate libwebp.so.6
    to find its path. Then add its path to your env lib path

  • 0 Votes
    4 Posts
    229 Views
    JonBJ

    @dark_matter_io
    So this is presumably a Qt6 issue rather than PyQt/PySide/Python. You can report at https://bugreports.qt.io/secure/Dashboard.jspa

  • 0 Votes
    2 Posts
    165 Views
    JonBJ

    @markleo
    PySide is not a language. It's just a bunch of Python code bindings to Qt functions written in C++. So your question is just about Python. To which you have answered that "Python is a weakly - typed language".

  • QTableView rows disabled?

    Solved
    9
    0 Votes
    9 Posts
    407 Views
    MasterQM

    @JonB said in QTableView rows disabled?:

    Then you will have to break down/build up till you find the difference in your code! Start by removing "front end identity model", just test directly on model (maybe non-SQL one as well as SQL one) and build back up from there.

    If I would like to find a reason for that behavior!

    At the moment I am satisfied to know about. There is an easy workaround as to set all flags by hand independently to what the framework does. That's enough for now. ... at least for me.

    I am sorry, but to dig deeper into the issue is actually out of my scope.

  • Error in exe file

    Unsolved
    3
    0 Votes
    3 Posts
    177 Views
    JonBJ

    @Mahdi_2020 said in Error in exe file:

    IndexError: list index out of range

    line338: root_object = engine.rootObjects()[0]

    engine.rootObjects() is not an array or, more likely, is an empty array so [0] is out of range.
    If it works under Creator but not outside then presumably creating the engine/objects fails outside because something is not set up right in the environment.

    When I run my program exe file

    When using Python you do not have an executable file, just a bunch of .py file scripts.

  • QFileDialog not started in needs dir

    Unsolved
    21
    0 Votes
    21 Posts
    3k Views
    JonBJ

    @cjw25 said in QFileDialog not started in needs dir:

    But the compilers on the other OSs are complaining that passing in zero is deprecated

    What dos this mean?

  • How to Disable Hover Effect for Arrows in PYQT6 QTreeView?

    Unsolved
    1
    0 Votes
    1 Posts
    116 Views
    No one has replied
  • 1 Votes
    2 Posts
    168 Views
    S

    I've found a solution using QAbstractNativeEventFilter to grab the keyboard events that never make it to the standard Qt event system.

  • QStyleOptionViewItem.rect

    Solved
    9
    0 Votes
    9 Posts
    504 Views
    MasterQM

    @JonB said in QStyleOptionViewItem.rect:

    @MasterQ said in QStyleOptionViewItem.rect:

    no, there is really no rect, see the documentation of PySide I provided. The IDE is right!

    No, there is indeed a rect member!

    Thank you for that information.

    My last tests confirm your answer, I was wrong about missing rect. Sry for the confusion.

  • QSystemTrayIcon doesn't show messages

    Solved
    9
    1 Votes
    9 Posts
    733 Views
    superagaS

    @jsulm said in QSystemTrayIcon doesn't show messages:

    I think it is the title of your application, try to change that

    Hi @jsulm, many thanks for your reply.
    I just tried both: QApplication.setApplicationDisplayName and QApplication.setApplicationName, but do not work.

    Any other idea?
    Cheers