- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
窗口将显示,但在退出时崩溃。 coredump 显示 QtGui4.dll 中发生了一些错误。
我的环境是PyQt4.10.4(Qt4.8.5) 32bit版本,Windows 7(64bit)。有任何线索或建议来查明发生了什么吗?非常感谢。
删除一个或多个控件则不会发生崩溃。好奇怪……
settings_window.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingWindow</class>
<widget class="QWidget" name="SettingWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>465</width>
<height>439</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>50</x>
<y>350</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>180</x>
<y>350</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>40</x>
<y>170</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>label</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_3">
<property name="geometry">
<rect>
<x>110</x>
<y>170</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>40</x>
<y>230</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4">
<property name="geometry">
<rect>
<x>120</x>
<y>220</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_4">
<property name="geometry">
<rect>
<x>140</x>
<y>300</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
<widget class="QLabel" name="label_11">
<property name="geometry">
<rect>
<x>120</x>
<y>190</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLabel" name="label_12">
<property name="geometry">
<rect>
<x>130</x>
<y>250</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>100</y>
<width>56</width>
<height>14</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>label</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>20</y>
<width>163</width>
<height>40</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>label</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>checkbox</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>checkbox</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
设置窗口.py
#-*- coding: utf-8 -*-
import sys
from PyQt4.QtGui import qApp, QDialog, QApplication
from ui_settings_window import Ui_SettingWindow
class SettingWindow(QDialog, Ui_SettingWindow):
def __init__(self):
super(SettingWindow, self).__init__()
self.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = SettingWindow()
window.show()
sys.exit(app.exec_())
最佳答案
sip.setdestroyonexit(False) 解决了我的问题。这将是 pyqt 退出时崩溃的最终答案。 pyqt document说:
When the Python interpreter exits PyQt4 (by default) calls the C++ destructor of all wrapped instances that it owns. This happens in a random order and can therefore cause the interpreter to crash. This behavior can be disabled by calling the sip.setdestroyonexit() function.
PyQt5 always calls sip.setdestroyonexit() automatically.
另一个引用应该是这个 post ,pyqt的作者讲了sip.setdestroyonexit()。
关于python - PyQt4 在退出时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23565702/
我目前正在为 Cocoa/Objective-C 项目编写一个脚本来完全自动化我的编译-运行-调试过程。 我的最后一行代码是: lldb -f Build/MyApp.app -o "run" 这实际
我有一个带有登录屏幕的脚本,如果按下取消按钮,我想完全退出该应用程序。我尝试了 3 种方法: 系统退出() QApplication.quit() QCoreApplication.instance(
我有一个 Flash 应用程序,可以重定向到另一个页面。我很乐意捕获任何其他窗口卸载事件(单击链接/提交表单)并警告用户他们将丢失 Flash 应用程序中的进度。 但是,我找不到任何方法来判断 URL
我正在尝试在 Ubuntu 上用 Python 编写一个简单的程序,它将在播放视频完成后关闭/退出/退出 VLC Player。 能否请您指导我应该在我的程序中添加什么以获得我需要的结果。 impor
我在 Lynda.com 上学习 PHP 2 视频时遇到了一个问题,因为讲师似乎忽略了告诉我们他在视频中执行的步骤之一。我在这里上传了相关视频http://www.youtube.com/watch?
某天在群内有同学问到,在python下我用input或者raw_input都得输入完后回车才能获取到输入的值,那如何实现任意键退出暂停等功能呢,我当时也没有多想,因为接触python时间也不算长,主
我按顺序调用了几个函数(我无法编辑),但有些函数会重定向用户,所以我永远不会进入下一个函数。 我正在调用一个第三方函数,它调用了我能够阻止的 wp_redirect(),但是下一行是 exit;我不知
终止/退出主函数的 D 方式是什么? import std.stdio; import core.thread; void main() { int i; while (i <= 5)
我正在申请写作。用户可以打开应用程序、写一些文本、保存他们的工作等。 我试图做到这一点,以便点击 window close按钮将提示用户 (a) 保存他们的工作(如有必要)或 (b) 退出。 我正在尝
我正在通过在 repl 中检查别人的代码来玩弄它。 它不断调用 System/exit,这导致我的 repl 崩溃。这真是令人气愤。 在我有权访问的所有代码中,我都模拟了调用。 但它也会调用一些我没有
我正在使用 subprocess执行mimic的模块程序(指定 here )。下面的代码成功地读取了一些文本并写入了一个 mp3 文件。 import subprocess proc = subpro
退出 .then 范围后数组上的值被清除 在下面的代码中tableValues1.length 给我正确的长度,直到它位于每个循环内当它退出时,作用域数组长度为零。 请谁能帮我解决这个问题 - 谢谢
我正在尝试为 s3cmd 编写一个 docker 镜像。当我通过 docker-compose 运行从 Dockerfile 构建的图像时,容器在 docker compose run 命令之前退出。
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicate: Quitting an application - is that frowned upon? 我编写了一个 And
我遇到 Selenium WebDriver 仅执行一次后退出 for 循环的问题。据推测,这是获取内容和在加载页面之前启动循环的问题。是否有可能让 webdriver 等待页面加载? List al
#include #include #include #include "Player.h" using namespace std; void PlayerMenu(); int main()
class Test{ public static void main(String args[]) { Patron list[] = new PatronData(
我正在做一些作业,遇到了这个问题。 Write a program that reads several lines of text and prints a table indicating the
我正在用 C 创建一个简单的 Linux 命令 shell。我无法理解我的代码在哪里出现问题。 “commands”是我希望作为一个父进程的子进程同时执行的 Linux 命令字符串列表。当所有执行完成
我的控制台应用程序有点问题。应用程序应该从用户那里获取数字并将它们添加到列表中,但是如果输入是“c”,它应该关闭。我不知道如何在不使用 Scanner.nextLine() 挂起应用程序并退出循环的情
我是一名优秀的程序员,十分优秀!