书名说明了一切。在
假设我有一个简单的应用程序:
在主.py&>>>
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView
# Main Function
if __name__ == '__main__':
# Create main app
myApp = QApplication(sys.argv)
# Create a label and set its properties
appLabel = QQuickView()
appLabel.setSource(QUrl('main.qml'))
# Show the Label
appLabel.show()
# Execute the Application and Exit
myApp.exec_()
sys.exit()
在主.qml&>>>
^{pr2}$现在这个例子运行得很好。但假设我错了主.qml我写身高而不是身高。然后python代码就可以正常工作了,但是它将启动一个空窗口,没有任何错误消息。在
如何在python控制台中查看.qml文件中的错误?在6000行代码中发现错误是非常痛苦的。在
我使用的是PyQt 5.5.1、Anaconda 2.4.1(python3.5.1)、windows8.1
如果您只想在控制台上看到错误输出,那么您不需要做任何事情,因为Qt无论如何都会自动执行这些操作。例如,如果我在您的示例中将
height
更改为heigth
,那么以下消息将打印在stderr上:如果要在应用程序中引发异常,可以连接到statusChanged信号并从errors方法获取详细信息:
相关问题 更多 >
编程相关推荐