Results 1 to 5 of 5

Thread: QApplication Process seems to hang

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QApplication Process seems to hang

    All you are showing is a class definition without showing how it is being used. There are a number of dependencies that you are also not giving any details on (ViewBox, GraphcsView, PlotWidget, InfiniteLine). Maybe these are extensions provided by PyQt5 - they aren't part of the standard Qt widget set.

    So a little context would be helpful.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Jul 2020
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QApplication Process seems to hang

    The whole code came from: https://github.com/ChristophKirst/ClearMap2. He build a DataViewer to look at tif or numpy converted files.
    The Testcode to check if this class is working is:
    Qt Code:
    1. def _test():
    2. import numpy as np
    3. import ClearMap.Visualization.Qt.DataViewer as dv
    4.  
    5. img1 = np.random.rand(*(100,80,30));
    6.  
    7. dv.DataViewer(img1)
    To copy to clipboard, switch view to plain text mode 
    its in ClearMap/Visualization/Qt/DataViewer.py

    I think it's so basic that it isn't helpful at all. Most interesting part is that the creator and at least 2 others are able to use the Viewer. So the problem shouldn't be in the code itself more about dependencies or the OS. I now try to clone the exact OS he's using. As you see I'm just started using linux and python code, so I don't really know what to do.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QApplication Process seems to hang

    OK, the problem with the test code is that it does not create a QApplication instance, does not call dv.show() (although the __init__ method for DataViewer -does- call it, which it shouldn't). Your test code should look more like this:

    Qt Code:
    1. def _test() :
    2. import sys
    3. from PyQt5.QtWidgets import QApplication
    4. from PyQt5.QtCore import Qt
    5.  
    6. import numpy as np
    7. import ClearMap.Visualization.Qt.DataViewer as dv
    8.  
    9. app = QApplication(sys.argv)
    10.  
    11. img1 = np.random.rand(*(100,80,30));
    12.  
    13. myViewer = dv.DataViewer(img1)
    14.  
    15. myViewer.show()
    16.  
    17. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    The reason the widget works inside a normal application is because the application almost certainly creates the QApplication instance and calls its exec() method so that the normal Qt event loop is up and running and the widget is responding to events. The original _test() method did none of that. Modifying it so it behaves like a mini-standalone app fixes that.
    Last edited by d_stranz; 8th July 2020 at 17:29.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. The following user says thank you to d_stranz for this useful post:

    SaibotMagd (8th July 2020)

  5. #4
    Join Date
    Jul 2020
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Lightbulb Re: QApplication Process seems to hang

    Quote Originally Posted by d_stranz View Post
    OK, the problem with the test code is that it does not create a QApplication instance, does not call dv.show() (although the __init__ method for DataViewer -does- call it, which it shouldn't). Your test code should look more like this:

    The reason the widget works inside a normal application is because the application almost certainly creates the QApplication instance and calls its exec() method so that the normal Qt event loop is up and running and the widget is responding to events. The original _test() method did none of that. Modifying it so it behaves like a mini-standalone app fixes that.
    I barely know what to say, Im in tears. Thats phantastic thank you very very much. It works great and I believe I can implement the solution into the package, and I will do it.

    Great work!

  6. The following user says thank you to SaibotMagd for this useful post:

    d_stranz (9th July 2020)

Similar Threads

  1. The GUI is hang
    By ugiwgh in forum Qt Programming
    Replies: 6
    Last Post: 7th November 2014, 11:04
  2. Using QApplication::processEvents - possible hang under linux
    By SpanishJohn in forum Qt Programming
    Replies: 4
    Last Post: 9th January 2014, 11:43
  3. BlockingQueuedConnection hang
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 17th February 2010, 18:30
  4. How to get the Process ID of my QApplication ?
    By Comer352l in forum Qt Programming
    Replies: 4
    Last Post: 29th November 2008, 10:11
  5. how can I get the QApplication handle by process ID in QT2
    By pencilren in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2007, 20:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.