[英]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.