本文介绍了调用 show() 后 QWidget 不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个 QWidget 在我调用 show() 后没有显示,即使 isVisible 返回 true.

In My App, I have a QWidget which is not showing after I call show(), even though isVisible returns true.

这个小部件是从主应用程序窗口的事件中创建的.但是当它自己启动时,即作为应用程序上唯一的小部件时,它会正常显示.

This widget is created from an event of the main application window. But when its started on its own, i.e., as the only widget on an app, it shows up normally.

有谁知道是什么导致了这种行为?

Anyone knows what may cause this behavior?

我的应用程序中的其他小部件通常会显示,只有这个小部件给我带来了麻烦.它实际上在以前版本的 Qt4 下工作得很好(不记得是哪个).

Other widgets in my app show up normally only this one is giving me troubles. It actually use to work just fine under a previous version of Qt4 (don't remember which).

小部件的代码在这里

更新:窗口似乎出现并立即销毁.

update: windows seems to appear and is immediately destroyed.

推荐答案

相关代码在hidx/GUI/main.py:

@pyqtSignature("")
def on_actionScatterplot_Matrix_activated(self):
    ...
    spm = scatmat.ScatMat(pars, self.currentdbname)
    print "==>", spm.pw.isVisible()
    spm.pw.hide()
    spm.pw.showMaximized()
    print spm.pw.size()
    print "==>", spm.pw.isVisible()

@pyqtSignature("int")
def on_rowStart_valueChanged(self, p0):
    ...

on_actionScatterplot_Matrix_activated 中,您创建了一个ScatMat 的实例,但不要保留对它的引用.因此该窗口将被简要显示,然后在函数完成后立即进行垃圾回收.

In on_actionScatterplot_Matrix_activated, you create an instance of ScatMat, but don't keep a reference to it. So the window will be briefly shown, and then immediately garbage-collected once the function completes.

这篇关于调用 show() 后 QWidget 不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:26