Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PyQt, Widgets, and Threading. Simple example of incorrect GUI update?
Forum Updated to NodeBB v4.3 + New Features

PyQt, Widgets, and Threading. Simple example of incorrect GUI update?

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 318 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sw_johannes
    wrote on 1 Nov 2024, 02:53 last edited by
    #1

    Hello community,

    I want to demonstrate students PyQt (I use PyQt5 on Windows) GUI Widgets Application and Threading with samples as simple as possible. I have one sample to show a blocking app without threading, to motivate the use of threading in the first place. And I have another sample showing the correct useage of PyQt Widges and QThreads and signals and slots.
    What I am looking for is a sample for incorrect GUI update, directly from a worker thread. I tried hard, but I couldn't get any exceptions or even noticable effects. The GUI still updates more or less correctly. Maybe someone has a sample or could think of a Widget that is more sensitive to thread updates. QLabel, and QListWidget just seem to be too robust to show real problems.
    So any ideas on provoking this? Hope my question is understandable.

    Best regards
    Johannes

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Nov 2024, 19:39 last edited by
      #2

      Hi,

      While it's a pretty goal to show why it's wrong to update widgets from a different thread, you might have issue reproducing this at will. This is in the zone of undefined behaviour and depends highly on the OS beside what you are modifying and it might just work for a while, do something funky or crash the application.
      Also, there might also be the architecture of Python itself that could be at play since it's currently not a true multithreaded language if you take the GIL into account.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      1/2

      1 Nov 2024, 02:53

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved