【问题标题】:Remove warnings from the console从控制台中删除警告
【发布时间】:2014-02-12 02:27:17
【问题描述】:

如何从控制台删除警告,例如以下警告:

 QObject::startTimer: QTimer can only be used with threads started with QThread
 QObject::startTimer: QTimer can only be used with threads started with QThread
 QObject::startTimer: QTimer can only be used with threads started with QThread

更新:这只是一个猜测,因为我正在使用 ElementTree 将 XML 文档解析为元素树:

    def parse(source, parser=None):
   tree = ElementTree()
   tree.parse(source, parser)
   return tree

如果您能指导我使用除 ElementTree 之外的其他解析器,我将不胜感激。

【问题讨论】:

  • 您的意思是一般性警告,还是只是与 QObject 相关的警告?
  • @RaydelMiranda 这是一条来自 Qt 的警告消息,如果出现问题,它会在 runtime 中发布。
  • 当我关闭 Qwidget 窗口时,它会显示在我的控制台中。是的,我的意思是如何从控制台解决此特定警告..
  • 你为什么不发布更多(相关)代码?否则将很难诊断您的情况。
  • 查看this question 以及本网站上可能找到的其他一些相关问题。

标签: python qt pyqt warnings elementtree


【解决方案1】:

这不是警告,而是错误,你不应该“删除它”,你应该修复它。 发生这种情况是因为您使用了不是从 QThread 启动的线程中的 QObject。可能您正在使用本机 python 线程。改用 QThread,你会没事的。 XML 的东西是一条红鲱鱼,似乎无关紧要。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-17
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 2014-02-28
    • 1970-01-01
    • 2015-11-26
    相关资源
    最近更新 更多