问题标签 [pyqt4]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2050 浏览

python - 通过 Qt 播放音频的最佳方式是什么?

我正在 pyQt4 中构建一个应用程序,我希望它能够播放音频文件。我正在考虑通过pyMedia执行此操作,因为我无法从文档中获得任何信息,尽管 QAudio 类最初看起来很有希望。解决方案必须是跨平台的,这一点很重要。有没有人有什么建议?

0 投票
2 回答
1348 浏览

python - QT4、GTK+、wxWidgets 或 IronPython,用于使用 Python 的原生 Windows 应用程序

我需要使用 Python(和 py2exe,我猜)构建本机 Windows 应用程序。

功能要求是:

  1. 任务栏图标
  2. 警报通知(在任务栏图标旁边)
  3. 无铬窗(最好是漂亮、圆形、彩色的)。
  4. Webkit 渲染一些 Chromeless 窗口

到目前为止,我已经确定了以下可能的工具包:

  • pyGTK
  • pyQT4
  • wxWidgets
  • 铁蟒

我以前没有使用过这些中的任何一个,因此我向您寻求有关选择上述之一的适用性或陷阱的建议。

非常感谢您的想法!

富有的

PS:我考虑过并打折了 Titanium 和 Air;Air 因运行时而出局,Titanium 因编译/部署模型而出局。

编辑:这里有希望(阅读:开发中)用于 QT 的 LGPL Python 绑定(为什么 pyQT 不能刚刚完成 LGPL 我不知道):http ://www.pyside.org/

0 投票
1 回答
1575 浏览

pyqt4 - PyQT4 issue with jpeg when compiled

In a PyQT4 program, I have a QLabel displaying an image with the following code :

in the init code :

in the resize method :

When I execute my script with python, it works fine, and I can display .bmp and JPEG files. If I compile it using py2exe however, I will only be able to display .bmp files. JPEG File display will fail with :

EDIT : It is a duplicate of this question

0 投票
2 回答
1794 浏览

python - pyqt jpeg 支持不以捆绑形式工作

要在 PyQT 应用程序中启用 jpeg 支持,您必须手动包含qjpeg4.dll.
当 dll 和 pyd 文件没有在最终的 exe 中捆绑在一起时,它可以正常工作。例如,使用 py2exe 您可以执行以下操作:

但是,如果您做同样的事情,并将 dll 捆绑在 exe 中(使用"bundle_files":1),则会失败并显示以下消息:

如何正确捆绑应用程序?

0 投票
2 回答
299 浏览

python - 如何防止 Qt 按钮出现在单独的框架中?

我正在开发一个 PyQt 应用程序。目前,有一个状态面板(定义为 a QWidget),其中包含一个QHBoxLayout. 此布局经常使用QPushButton由应用程序的另一部分创建的 s 进行更新。

每当出现的按钮需要更改(这是相当频繁的)时,就会调用更新效果。从布局中删除现有按钮(通过调用layout.removeWidget(button)then button.setParent(None))并将新按钮添加到布局中。

一般来说,这是可行的。但偶尔,当我调用button.setParent(None)删除按钮时,它会导致它弹出应用程序并开始浮动在自己的独立框架中。

如何从布局中删除按钮并确保它不会开始浮动?

0 投票
3 回答
63811 浏览

python - 如何在 PyQt4 中将图片添加到 QWidget

如何将图片添加或导入到QWidget? 我找到了线索。我可以在该标签中添加一个Label并添加一个。Picture我需要QPicture(). 我可以使用的可能性是,QLabel.setPicture(self.QPicture)

0 投票
1 回答
4135 浏览

python - PyQt4:隐藏小部件并调整窗口大小

我正在使用几个小部件,但解决方案不会出现。我所拥有的是一系列的按钮QHBoxLayouts。一些按钮默认是隐藏的,但它们会在需要时出现。为了解决空间问题,所有按钮都有最小和最大尺寸,因此它们看起来总是包装得很好。我也有一个QTextEdit,默认可见,它在一个QVBoxLayout带有QHBoxLayout按钮的

所以问题是这样的:当我隐藏QTextEdit并显示其他按钮时,窗口不会调整大小。搜索后我发现 usingself.ui.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize)可以解决问题,但问题是它从所有小部件中获取最大尺寸,因此我结束了一个巨大的窗口。这样做self.ui.layout().setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize)不会调整窗口大小

我已经尝试过使用self.ui.resize(0,0),并且在执行时self.ui.layout().update()我得到了 False (我觉得很奇怪,http://doc.trolltech.com/4.6/qlayout.html#activate),并且还尝试覆盖sizeHint()但它一直使用最大大小所有小部件。

有没有办法调整窗口大小并同时处理小部件的最小和最大尺寸?

提前致谢

0 投票
1 回答
2185 浏览

qt - QWebView not loading external resources

I'm working on a kiosk web browser using Qt and PyQt4. QWebView seems to work quite well except for one quirk.

If a URL fails to load for any reason, I want to redirect the user to a custom error page. I've done this using the loadFinished() signal to check the result, and change the URL to the custom page if necessary using QWebView.load(). However, any page I attempt to load here fails to pull in external resources like CSS or images.

Using QWebView.load() to set the initial page at startup seems to work fine, and clicking any link on the custom error page will result in the destination page loading fine. It's just the error page that doesn't work.

I'm really not sure where to go next. I've included the source for an app that will replicate the problem below. It takes a URL as a command line argument - a valid URL will display correctly, a bad URL (eg. DNS resolution fails) will redirect to Google, but with the logo missing.

If anyone could offer some advice it would be greatly appreciated.

0 投票
2 回答
5094 浏览

python - 如何从 PyQt4 中的 QVariant 取回我的 python 对象?

我正在创建一个QAbstractItemModel要显示在QTreeView.

我的index()and函数使用继承parent()的函数创建并为其提供,和需要的。在这里,出于测试目的,数据是 Python 字符串。QModelIndexQAbstractItemModelcreateIndexrowcolumndata

index()parent()data()函数中,我需要取回我的数据。它以QVariant. 如何从 QVariant 取回我的 Python 对象?

0 投票
1 回答
246 浏览

python - PyQt4:将 QtMessageBox.information 功能添加到自定义窗口

我需要的是非常相似的 QtMessageBox.information 方法,但我需要它形成我的自定义窗口。

我需要一个带有少量标签的窗口,一个 QtTreeViewWidget,一个 QButtonGroup……这个窗口将从主窗口调用。如果我们将实现称为窗口的类称为 SelectionWindow,那么我需要的是:

来自 SelectionWindow 的方法 getSelection 应该会弹出选择窗口,并在最后返回 QTreeViewWidget 中选择的行。我希望主窗口保持阻塞状态,直到用户在选择窗口中选择一行并通过按钮确认。我希望你能理解我的需要。

我将不胜感激任何帮助!

谢谢,蒂霍