Results 1 to 5 of 5

Thread: QApplication Process seems to hang

Threaded View

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

    Default QApplication Process seems to hang

    Hello,

    I'm a somewhat programming and python nooby and I have to implement a pipeline in my institut. A researcher create a dataviewer in the tutorial file using PyQt5 but even the test-function push the process into a hanging state (kernel is forced to restart after the window is terminated). i.e. it creates a pop-up window with the correct name and resolution but the window itself is black without any widgets and it halts immediately.

    I know it's a somewhat impossible mission to find the solution but maybe someone got a climse of a idea what I could try next.

    Qt Code:
    1. class DataViewer(pg.QtGui.QWidget):
    2. def __init__(self, source, axis = None, scale = None, title = None, invertY = False, minMax = None, screen = None, parent = None, *args):
    3.  
    4. ### Print pointer to QApplication Instance (we now know that at this time a QApp is initalized)
    5. print(pg.QtGui.QApplication.instance())
    6. print(pg.QtGui.QApplication.allWidgets())
    7.  
    8. ### Images soures
    9. self.initializeSources(source, axis = axis, scale = scale)
    10. #print('init')
    11. ### Gui Construction
    12. pg.QtGui.QWidget.__init__(self, parent, *args);
    13. #print('gui')
    14.  
    15. if title is None:
    16. if isinstance(source, str):
    17. title = source;
    18. elif isinstance(source, io.src.Source):
    19. title = source.location;
    20. if title is None:
    21. title = 'DataViewer';
    22. self.setWindowTitle(title);
    23. self.resize(1600,1200)
    24. #print('title')
    25.  
    26.  
    27. self.layout = pg.QtGui.QGridLayout(self);
    28. self.layout.setContentsMargins(0,0,0,0)
    29. #print('layout')
    30.  
    31. # image pane
    32. self.view = pg.ViewBox();
    33. self.view.setAspectLocked(True);
    34. self.view.invertY(invertY)
    35.  
    36. self.graphicsView = pg.GraphicsView()
    37. self.graphicsView.setObjectName("GraphicsView")
    38. self.graphicsView.setCentralItem(self.view)
    39.  
    40. splitter = pg.QtGui.QSplitter();
    41. splitter.setOrientation(pg.QtCore.Qt.Horizontal)
    42. splitter.setSizes([self.width() - 10, 10]);
    43. self.layout.addWidget(splitter);
    44.  
    45. image_splitter = pg.QtGui.QSplitter();
    46. image_splitter.setOrientation(pg.QtCore.Qt.Vertical)
    47. image_splitter.setSizePolicy(pg.QtGui.QSizePolicy.Expanding, pg.QtGui.QSizePolicy.Expanding)
    48. splitter.addWidget(image_splitter);
    49. #print('image')
    50.  
    51. # Image plots
    52. image_options = dict(clipToView = True, autoDownsample = True, autoLevels = False, useOpenGL = None);
    53. self.image_items = [pg.ImageItem(s[self.source_slice[:s.ndim]], **image_options) for s in self.sources];
    54. for i in self.image_items:
    55. i.setRect(pg.QtCore.QRect(0, 0, self.source_range_x, self.source_range_y))
    56. i.setCompositionMode(pg.QtGui.QPainter.CompositionMode_Plus);
    57. self.view.addItem(i);
    58. self.view.setXRange(0, self.source_range_x);
    59. self.view.setYRange(0, self.source_range_y);
    60. #print('plots')
    61.  
    62. # Slice Selector
    63. self.slicePlot = pg.PlotWidget()
    64. sizePolicy = pg.QtGui.QSizePolicy(pg.QtGui.QSizePolicy.Preferred, pg.QtGui.QSizePolicy.Preferred)
    65. sizePolicy.setHorizontalStretch(0)
    66. sizePolicy.setVerticalStretch(0)
    67. sizePolicy.setHeightForWidth(self.slicePlot.sizePolicy().hasHeightForWidth())
    68. self.slicePlot.setSizePolicy(sizePolicy)
    69. self.slicePlot.setMinimumSize(pg.QtCore.QSize(0, 40))
    70. self.slicePlot.setObjectName("roiPlot");
    71. #self.sliceCurve = self.slicePlot.plot()
    72.  
    73. self.sliceLine = pg.InfiniteLine(0, movable=True)
    74. self.sliceLine.setPen((255, 255, 255, 200))
    75. self.sliceLine.setZValue(1)
    76. self.slicePlot.addItem(self.sliceLine)
    77. self.slicePlot.hideAxis('left')
    78.  
    79. self.updateSlicer();
    80.  
    81. self.sliceLine.sigPositionChanged.connect(self.updateSlice)
    82. #print('slice')
    83.  
    84. # Axis Tools
    85. axis_tools_layout = pg.QtGui.QGridLayout()
    86. self.axis_buttons = [];
    87. axesnames = ['x', 'y', 'z'];
    88. for d in range(3):
    89. button = pg.QtGui.QRadioButton(axesnames[d]);
    90. button.setMaximumWidth(50);
    91. axis_tools_layout.addWidget(button,0,d);
    92. button.clicked.connect(ft.partial(self.setSliceAxis, d));
    93. self.axis_buttons.append(button);
    94. self.axis_buttons[self.source_axis].setChecked(True);
    95. axis_tools_widget = pg.QtGui.QWidget();
    96. axis_tools_widget.setLayout(axis_tools_layout);
    97. #print('axis')
    98.  
    99. # coordinate label
    100. self.source_pointer = [0,0,0];
    101. self.source_label = pg.QtGui.QLabel("");
    102. axis_tools_layout.addWidget(self.source_label,0,3);
    103.  
    104. self.graphicsView.scene().sigMouseMoved.connect(self.updateLabelFromMouseMove);
    105. #print('coords')
    106.  
    107. #compose the image viewer
    108. image_splitter.addWidget(self.graphicsView);
    109. image_splitter.addWidget(self.slicePlot)
    110. image_splitter.addWidget(axis_tools_widget);
    111. image_splitter.setSizes([self.height()-35-20, 35, 20])
    112. #print('viewer')
    113.  
    114. # lut widgets
    115. if self.nsources == 1:
    116. cols = ['flame'];
    117. elif self.nsources == 2:
    118. cols = ['purple', 'green'];
    119. else:
    120. cols = np.array(['white', 'green','red', 'blue', 'purple'] * self.nsources)[:self.nsources];
    121.  
    122. self.luts = [LUT(image = i, color = c) for i,c in zip(self.image_items, cols)];
    123.  
    124. lut_layout = pg.QtGui.QGridLayout();
    125.  
    126. lut_layout.setContentsMargins(0,0,0,0);
    127. for d,l in enumerate(self.luts):
    128. lut_layout.addWidget(l,0,d);
    129. lut_widget = pg.QtGui.QWidget();
    130. lut_widget.setLayout(lut_layout);
    131. lut_widget.setContentsMargins(0,0,0,0);
    132. lut_widget.setSizePolicy(pg.QtGui.QSizePolicy.Preferred, pg.QtGui.QSizePolicy.Expanding)
    133. splitter.addWidget(lut_widget);
    134.  
    135. splitter.setStretchFactor(0, 1);
    136. splitter.setStretchFactor(1, 0);
    137.  
    138. # update scale
    139. for l in self.luts:
    140. l.range_buttons[1][2].click();
    141. if minMax is not None:
    142. self.setMinMax(minMax);
    143.  
    144. self.show();
    145. print(pg.QtGui.QApplication.instance())
    To copy to clipboard, switch view to plain text mode 

    What I found out till now:
    • the "allWidget()" function print out all widgets collected by the QApp. and this works finde
    • the code runs till the end (I got a instance pointer at the beginning and in the end; there're the same)
    • I tried several PyQt examples to test for openGL or non openGL Outputs and they all worked fine
    • there's no out-of-memory or CPU overload
    • I tried to cut the code per widget to find the issue, but whatever line of code I commented out no window pops-up anymore
    • I found this great article: https://doc.qt.io/archives/qq/qq27-r...tml#conclusion Could it be something like that?


    Like I said I'm not a programmer and I didn't write the code myself (the author don't answer right now). Its overwhelming but I have to find a solution. Any ideas what I could try next? Anything would be helpful.
    Last edited by SaibotMagd; 7th July 2020 at 17:57.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.