PDA

View Full Version : How to hide the dashed frame outside the QGraphicsItem .



robertkun
6th August 2009, 09:51
When you have select a QGraphcisItem in the QGraphicsScene,there is a dashed frame outside the Item .

but I want to hide the dashed frame ,Please help me ...

I am afraid these is no way to resolve it ...Thanks a lot..http://www.qtcn.org/bbs/attachment/Mon_0907/17_79354_8dd907b7645a245.jpg

yogeshgokul
6th August 2009, 10:17
I am afraid these is no way to resolve it
Thats easy, just set this flag to false.

item->setFlag(QGraphicsItem::ItemIsSelectable, false);

robertkun
6th August 2009, 13:45
Thats easy, just set this flag to false.

item->setFlag(QGraphicsItem::ItemIsSelectable, false);

Yes,that is ture,thank you . but if I have set the ItemIsSelectable false,How can I to select it .. Let me think think.thank you..

yogeshgokul
6th August 2009, 14:20
but if I have set the ItemIsSelectable false,How can I to select it
Re-Setting this flag, will not stop the item selection. It will just stop showing the rectangle. And this is what you want I guess.;)

robertkun
7th August 2009, 07:21
Now I am rewrite the function paint() of the QGraphicsPolygonItem,For example :

void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(widget);
if (dd->control) {
painter->save();
QRectF r = option->exposedRect;
painter->translate(-dd->controlOffset());
r.translate(dd->controlOffset());
dd->control->drawContents(painter, r);
painter->restore();
}

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

the last two sentences is the Selected state,and delete them.

yogeshgokul
7th August 2009, 08:17
Did you try setting that flag?
If yes, what happened?

robertkun
7th August 2009, 10:39
http://www.qtcn.org/bbs/attachment/Mon_0908/17_79354_2315c0910bf1977.jpg

look this image from my project ,if I press the circular the right side property tabpage
show nothing ,because the item don't selecte.

So this is the matter of set the flag...

thank you .

Lykurg
7th August 2009, 18:06
before rewriting any Qt-function spend 1 minute on our search engine, because that is a very often asked question! simply remove the QStyle::State_Selected option in your paint method!