简体   繁体   English

在非GUI线程中获取文件图标(QFileIconProvider :: icon)

[英]Getting file icons (QFileIconProvider::icon) in non-gui thread

I'm trying to get file icons from non-gui thread to avoid gui freeze. 我正在尝试从非GUI线程获取文件图标,以避免GUI冻结。 I'm getting the warning: 我收到警告:

QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap:在GUI线程外使用像素图并不安全

Is there a way to solve my problem? 有办法解决我的问题吗? Maybe there is another simple way to get file icons? 也许还有另一种简单的方法来获取文件图标? My target system is Ubuntu, I don't need to support other systems. 我的目标系统是Ubuntu,我不需要支持其他系统。

Well you can use QImage instead to load file-icons which can be used outside GUI thread . 好了,您可以改用QImage来加载可在GUI线程外使用的文件图标。 And then you can use any function provided by QImage to convert it into QPixmap . 然后,您可以使用QImage提供的任何函数将其转换为QPixmap For example following static function: 例如下面的static函数:

QPixmap QImage::fromImage (const QImage & image, Qt::ImageConversionFlags flags)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从另一个非GUI线程启动QTimer - Start QTimer from another non-gui thread 如何在非GUI线程上正确创建QUdpSocket? 已读未发出 - How to properly create QUdpSocket on non-gui thread ? Readyread not emitted QFileIconProvider返回相同的图标,无论文件如何 - QFileIconProvider returns the same icon regardless of file 如何从non_GUI类和我们可以在主GUI类中检测到的非GUI线程发出信号 - how to emit a signal from a non_GUI class and from a non-GUI thread which we can detect in main GUI class Dock Icon两次相同实例和Non-Gui进程错误地标记为“不响应” - Dock Icon twice of same instance and Non-Gui process wrongly tagged “not responding” VC ++中用于非GUI应用程序的计时器 - Timer in VC++ for Non-GUI Applications 将 MouseDown 与 SuperCollider 一起使用:非 GUI 实现 - Using MouseDown with SuperCollider: non-GUI implementation 在Visual Studio中创建非GUI服务器应用程序 - Make Non-GUI server application in Visual Studio 在 C++ 非 GUI 应用程序中检测 USB 插入/移除 - Detecting USB insertion/Removal in C++ non-GUI application 在仍然进行非GUI工作的同时,如何以预定间隔更新GUI? - How to update the GUI at a pre-determined interval, while still doing non-GUI work?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM