Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 窗口关闭后部件冻结_Qt_User Interface_Qt5_Qmainwindow - Fatal编程技术网

Qt 窗口关闭后部件冻结

Qt 窗口关闭后部件冻结,qt,user-interface,qt5,qmainwindow,Qt,User Interface,Qt5,Qmainwindow,我正在为一个应用程序使用Qt5 Creator,在主窗口的构造函数中我调用this->setWindowsState(Qt::WindowMaximized)。当窗口最初最大化时,单选按钮和复选框工作正常(即在选中和未选中之间轻松切换) 但是,如果我将其最小化并最大化,则单选按钮和复选框似乎会冻结,无法自由切换。但如果我真的恢复下来,一切都会好起来的 我尝试在单选按钮和复选框的插槽中包含一个this->update,但没有成功。任何帮助都将不胜感激。当您使用this->setWindowStat

我正在为一个应用程序使用Qt5 Creator,在主窗口的构造函数中我调用
this->setWindowsState(Qt::WindowMaximized)
。当窗口最初最大化时,单选按钮和复选框工作正常(即在选中和未选中之间轻松切换)

但是,如果我将其最小化并最大化,则单选按钮和复选框似乎会冻结,无法自由切换。但如果我真的恢复下来,一切都会好起来的


我尝试在单选按钮和复选框的插槽中包含一个
this->update
,但没有成功。任何帮助都将不胜感激。

当您使用
this->setWindowState(Qt::WindowMaximized)您可能正在重写windows的其他状态属性。特别是,您正在删除
Qt::WindowActive
。因此,使用以下两种方法之一

this->setWindowState(this->windowState() | Qt::WindowMaximized);
this->setWindowState(Qt::WindowMaximized | Qt::WindowActive);

但我想知道你为什么要玩弄WindowState。您不能在构造函数中使用
show()
使窗口可见吗?

当您使用
this->setWindowsState(Qt::WindowMaximized)时您可能正在重写windows的其他状态属性。特别是,您正在删除
Qt::WindowActive
。因此,使用以下两种方法之一

this->setWindowState(this->windowState() | Qt::WindowMaximized);
this->setWindowState(Qt::WindowMaximized | Qt::WindowActive);

但我想知道你为什么要玩弄WindowState。您不能在构造函数中使用
show()
使窗口可见吗?

试试
this->showmimized()
。窗口状态可用于执行任何其他方法都无法完成的复杂操作,但如果其他方法提供了所需的功能(本例中为QWidget::showMaximized()),请使用该状态。

尝试
此->showMaximized()
。窗口状态可用于执行通过任何其他方法都无法完成的复杂操作,但如果其他方法提供了所需的功能(本例中为QWidget::showMaximized()),请使用该状态。

我遇到了类似的问题

环境:Windows7+Qt5.3+无框架QMainWindow

我所做的:使用
QMainWindow::showmimized
最小化窗口,然后再次显示它

发生了什么:窗口停止重新绘制。它看起来冻结了

我正在调试它,并发现以下内容:

最小化窗口属性后,QMainWindow中删除了
Qt::WA_Mapped
(您可以在
qwidget.cpp
中将断点设置为
setAttribute_internal
,以检查它)。但在显示窗口后,未再次设置此属性。这导致
QWidgetBackingStore::sync
中的条件
if(discardSyncRequest(tlw,tlwExtra))
未满足,并导致
dirtyWidgets
未清除。在Qt更新系统的其他部分,这导致没有进行其他渲染

我所做的解决方法:子类化
QMainWindow
,并在恢复窗口时手动设置属性
Qt::WA_映射(处理changeEvent):

这对我很有效。正确的解决方案可能是修复Qt中的bug

关于问题的更多信息

我在Qt项目历史记录中发现了类似的错误(标记为关闭):

Qt论坛中也有类似问题:

我在
QWidgetBackingStore::sync

// If the top-level is minimized, it's not visible on the screen so we can delay the
// update until it's shown again. In order to do that we must keep the dirty states.
// These will be cleared when we receive the first expose after showNormal().
// However, if the widget is not visible (isVisible() returns false), everything will
// be invalidated once the widget is shown again, so clear all dirty states.

Qt内核中似乎有一个bug(可能提到了QTBUG-34147)已经解决了,但仍然存在一些问题。

我遇到了类似的问题

环境:Windows7+Qt5.3+无框架QMainWindow

我所做的:使用
QMainWindow::showmimized
最小化窗口,然后再次显示它

发生了什么:窗口停止重新绘制。它看起来冻结了

我正在调试它,并发现以下内容:

最小化窗口属性后,QMainWindow中删除了
Qt::WA_Mapped
(您可以在
qwidget.cpp
中将断点设置为
setAttribute_internal
,以检查它)。但在显示窗口后,未再次设置此属性。这导致
QWidgetBackingStore::sync
中的条件
if(discardSyncRequest(tlw,tlwExtra))
未满足,并导致
dirtyWidgets
未清除。在Qt更新系统的其他部分,这导致没有进行其他渲染

我所做的解决方法:子类化
QMainWindow
,并在恢复窗口时手动设置属性
Qt::WA_映射(处理changeEvent):

这对我很有效。正确的解决方案可能是修复Qt中的bug

关于问题的更多信息

我在Qt项目历史记录中发现了类似的错误(标记为关闭):

Qt论坛中也有类似问题:

我在
QWidgetBackingStore::sync

// If the top-level is minimized, it's not visible on the screen so we can delay the
// update until it's shown again. In order to do that we must keep the dirty states.
// These will be cleared when we receive the first expose after showNormal().
// However, if the widget is not visible (isVisible() returns false), everything will
// be invalidated once the widget is shown again, so clear all dirty states.

Qt内核中似乎有一个bug(可能提到了QTBUG-34147)已经解决了,但仍然存在一些问题。

您是否只有GUI而没有任何其他代码?有代码……但这是在没有代码的情况下发生的。我也在使用Qt5 Creator Qt5 Creator?你的意思是Qt5和QtCreator??你只有GUI而没有任何其他代码吗?有代码…但这是在没有代码的情况下发生的,我也在使用Qt5 Creator Qt5 Creator?你是说Qt5和QtCreator?太棒了!我刚刚发现了这篇文章,它解决了我多年来一直在处理的一个问题,谢谢!我在向小部件添加libvlc时遇到了这个问题,即使没有最小化。我希望我能多投一票。太棒了!我刚发现这篇文章,它解决了我多年来一直在处理的问题,谢谢!我在向小部件添加libvlc时遇到了这个问题,即使没有最小化。我希望我能投多一票。