久久久久久久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 ()?環形?)
主站蜘蛛池模板: 成人av一区二区三区在线观看 | аⅴ资源新版在线天堂 | 蜜臀久久99精品久久久久宅男 | 正在播放国产精品 | 91在线精品一区二区 | 四虎永久在线 | 精品一区二区三区在线观看 | 国产精品主播一区二区 | 欧美一级在线视频 | 国产自在线| 亚洲亚洲人成综合网络 | 久久久久久久久久久国产 | 成人一级视频 | 国产精品久免费的黄网站 | 国产欧美一区二区三区视频在线观看 | 欧美日韩国产一区 | 日韩精品极品视频在线观看免费 | 亚洲成年人在线观看 | 久久精品在线观看 | 成人av在线看 | 国产无遮挡又黄又爽免费网站 | 精品国产一二三区 | 久草久草 | 懂色av蜜臀av粉嫩av分享 | 久久久久久黄色 | 黄色av免费在线观看 | 国内精品国产成人国产三级 | 久久在线精品 | 色女人影院 | 久久亚洲成人 | 美国一级大黄一片免费中文 | 日韩高清一区二区 | 日韩在线视频免费 | 亚洲性猛交 | 男同在线观看 | 日本理伦片午夜理伦片 | 日韩中文一区 | 视频一二区 | 中文字幕免费高清 | 黄频在线观看 | 国产在线一区二区 |