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

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

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

問題描述

我想向 QGraphicsItem 添加信號(hào)/插槽,以便我可以從另一個(gè)線程訪問 QGraphicsItemObjects.我知道有兩個(gè)選項(xiàng):使用 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.

這被認(rèn)為是緩慢的.根據(jù) this answer on stackoverflow QGraphicsObjects 很慢,因?yàn)樗鼈儓?zhí)行.當(dāng)我查看 QGraphicsObjects 的源代碼時(shí),我可以看到根據(jù)對(duì)對(duì)象所做的更改發(fā)出了很多信號(hào).對(duì)我來說,這似乎是 QGraphicsObjects 緩慢的一個(gè)合理的論點(diǎn),但我認(rèn)為這種性能下降(如果真的是)可以通過第二種解決方案來避免.

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.

當(dāng)構(gòu)造一個(gè)繼承自 QObject 和 QGraphicsItem 的類時(shí),您似乎獲得了 QGraphicsObject 最有趣的特性減去性能損失:您可以在類中定義插槽并發(fā)出信號(hào),但您不繼承默認(rèn)實(shí)現(xiàn)的 QGraphicsObject 會(huì)在您可能不感興趣的更改時(shí)不斷發(fā)出信號(hào).您現(xiàn)在可以發(fā)出信號(hào),但不必?fù)?dān)心為您不關(guān)心的事情發(fā)出信號(hào)(更改的 x 值會(huì)發(fā)出信號(hào))在 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 慢嗎?
  • 如果是,是不是因?yàn)閷?shí)現(xiàn)會(huì)發(fā)出信號(hào)(并且發(fā)出信號(hào)是一個(gè)性能受到很大影響)?
  • 如果是這樣,第二種解決方案(多重繼承)是否避免了這種懲罰?

推薦答案

此線程 建議另一種選擇:創(chuàng)建一個(gè) QObject 子類來代表您的 QGraphicsItems 發(fā)出信號(hào).

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

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

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

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

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

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 国产欧美在线播放 | 欧美福利 | 亚洲一区二区三区四区av | 欧美日韩一区在线 | 欧美高清视频 | 在线免费观看a级片 | 国产高清视频在线观看播放 | 国产激情91久久精品导航 | 亚洲毛片在线观看 | 亚洲综合色视频在线观看 | 色婷婷久久久久swag精品 | 日韩在线中文字幕 | 国产精品资源在线观看 | 国精产品一品二品国精在线观看 | 免费电影av | 国产成人麻豆免费观看 | 一区二区免费 | xx性欧美肥妇精品久久久久久 | 妖精视频一区二区三区 | 亚洲欧美精品久久 | 色网站入口 | 伊人伊人伊人 | 在线午夜| 欧美亚洲高清 | 欧美人成在线视频 | 日韩人体视频 | 日本欧美国产在线观看 | 亚洲一区二区三区四区五区午夜 | 国产yw851.c免费观看网站 | 成年人网站在线观看视频 | 欧美精品福利视频 | 欧美国产亚洲一区二区 | 亚洲欧美成人影院 | 天天干国产 | 欧美一区二区三区精品免费 | 五月天婷婷激情 | 国产成人精品一区二区三区在线 | 在线免费毛片 | 一a一片一级一片啪啪 | 九九热热九九 | 一区二区日韩 |