QT 4.5 - Changing the selection marquee for QGraphicsItem

亡梦爱人 提交于 2019-12-10 13:54:51

问题


Is it possible to define the style of the selection marquee when a QGraphicsItem is set selectd via setSelected(true)?


回答1:


Technically no.

After a quick look into Qt's source code, it seems that the standard item types QGraphics*Item have the dashed outline as a default behavior. You can work around this by subclassing your own QGraphicsItem.

if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
    qt_graphicsItem_highlightSelected(this, painter, option);

I guess you can not change the "style". This seems to be a very static feature of the standard QGraphicsItems.

Hope that helps!




回答2:


There's a good solution at:

http://www.qtcentre.org/threads/15089-QGraphicsView-change-selected-rectangle-style



来源:https://stackoverflow.com/questions/1604995/qt-4-5-changing-the-selection-marquee-for-qgraphicsitem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!