久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

向 QGraphicsItem 添加信號/插槽(QObject):性能受到影響

Adding signals/slots (QObject) to QGraphicsItem: performance hit?(向 QGraphicsItem 添加信號/插槽(QObject):性能受到影響?)
本文介紹了向 QGraphicsItem 添加信號/插槽(QObject):性能受到影響?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想向 QGraphicsItem 添加信號/插槽,以便我可以從另一個線程訪問 QGraphicsItemObjects.我知道有兩個選項:使用 QGraphicsObject 或從 QObject 和 QGraphicsItem 繼承.

I want to add signals/slots to a QGraphicsItem so I can reach QGraphicsItemObjects from another thread. There are two options that I know of: use QGraphicsObject or inherit from QObject and QGraphicsItem.

這被認為是緩慢的.根據 this answer on stackoverflow QGraphicsObjects 很慢,因為它們執行.當我查看 QGraphicsObjects 的源代碼時,我可以看到根據對對象所做的更改發出了很多信號.對我來說,這似乎是 QGraphicsObjects 緩慢的一個合理的論點,但我認為這種性能下降(如果真的是)可以通過第二種解決方案來避免.

This is assumed to be slow. According to this answer on stackoverflow QGraphicsObjects are slow because of their implementation. When I look in the source of QGraphicsObjects I can see a lot of signals being emitted according to changes made to the object. To me this seems a plausible argument for why QGraphicsObjects are slow, but I think this performance hit (if it really is one) can be avoided by the second solution.

當構造一個繼承自 QObject 和 QGraphicsItem 的類時,您似乎獲得了 QGraphicsObject 最有趣的特性減去性能損失:您可以在類中定義插槽并發出信號,但您不繼承默認實現的 QGraphicsObject 會在您可能不感興趣的更改時不斷發出信號.您現在可以發出信號,但不必擔心為您不關心的事情發出信號(更改的 x 值會發出信號)在 QGraphicsObject 中,但不在此解決方案中).

When constructing a class that inherits from QObject and QGraphicsItem it seems that you get the most interesting feature of QGraphicsObject minus the performance hit: you are able to define slots and emit signals in your class but you don't inherit the default implementation of QGraphicsObject that would constantly emit signals on changes you might not be interested in. You are now able to emit signals but don't have to worry about signals being emitted for things you don't care about (x value that changes emits a signal in QGraphicsObject but not in this solution).

  • QGraphicsObjects 真的比 QGraphicsItems 慢嗎?
  • 如果是,是不是因為實現會發出信號(并且發出信號是一個性能受到很大影響)?
  • 如果是這樣,第二種解決方案(多重繼承)是否避免了這種懲罰?

推薦答案

此線程 建議另一種選擇:創建一個 QObject 子類來代表您的 QGraphicsItems 發出信號.

This thread suggests another option: Create a QObject subclass to emit signals on behalf of your QGraphicsItems.

如果你有很多 QGraphicsItems 可以共享一個 QObject,那么這將比讓每個 QGraphicsItem 繼承 QObject 更輕量級.

If you have many QGraphicsItems that can share a single QObject, then this will be lighterweight than having each QGraphicsItem inherit QObject.

這篇關于向 QGraphicsItem 添加信號/插槽(QObject):性能受到影響?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 91性高湖久久久久久久久_久久99 | 一区二区三区在线播放 | 二区欧美| 日韩成人影院 | 欧美嘿咻 | 欧美精品久久久久久久久久 | 亚洲精品电影网在线观看 | 精品久久久久久 | 日韩亚洲欧美综合 | 人人做人人澡人人爽欧美 | 91高清免费 | 亚洲码欧美码一区二区三区 | 久久伊人青青草 | 国产激情一区二区三区 | 性xxxxx| 521av网站 | 羞羞的视频免费在线观看 | 欧美综合一区 | 精品国产91亚洲一区二区三区www | 国产在线视频一区二区 | 亚洲v日韩v综合v精品v | 欧美激情在线一区二区三区 | 日本a∨视频 | 人人干人人艹 | 亚洲女人天堂成人av在线 | 日韩精品在线看 | 亚洲欧美在线视频 | 国产精品久久久爽爽爽麻豆色哟哟 | 国产乱码精品一区二区三区忘忧草 | 亚洲精品久久久久久下一站 | 精品一区国产 | 九九亚洲精品 | 精品欧美乱码久久久久久 | 精品欧美乱码久久久久久 | 欧美精品久久久久 | 天天操天天干天天透 | 国产在线一区二区三区 | 日本精品一区二区三区四区 | 天天拍天天草 | 久久久网| 日韩精品视频在线免费观看 |