PDA

View Full Version : view/item



goldhappywang
14th April 2009, 13:24
Hi,
I have a problem , I want to the view(like QGraphicsView) zoom in ,at the same time the items can't change,
some one tell me rewrite the paint() ,but I don't know how to do it? I seek to a share of code about the View/Items .
Thanks a lot!

wysota
14th April 2009, 23:18
I'm not sure I understand what you want, but assuming you want to zoom the view without zooming the items in it, you want to set QGraphicsItem::ItemIgnoresTransformations flag on each of the items.

goldhappywang
15th April 2009, 02:26
I have rewrite new view and items, they are't QGraphicsView and QGrphicsItem
But in the new Frame, I want to zoom the view without zooming the items in it

wysota
15th April 2009, 08:40
What's the problem then?

goldhappywang
15th April 2009, 09:49
it show blank space in the drawtext() ,in the first it show a QString, and it also scale when the view scale.
the code
begin:

void QzCanvasTagItem::paint(QPainter * painter)
{
drawText(Rect(), Qt::AlignLeft,_text);
}
it show a rect with text

after:

void QzCanvasTagItem::paint(QPainter * painter,QWidget *widget)
{
painter->save();
QWidget *w;
w = widget->parentWidget();

QzCanvasView *v;
v = (QzCanvasView *)w;
//In there, I don't konw what to do
drawText(Rect(), Qt::AlignLeft,_text);
painter->restore();
}

it show blank space ,the text disapper
and the Item also scale with view scale

wysota
15th April 2009, 09:52
And how is that related to zooming? What is QzCanvasTagItem? What drawText()? What is this code supposed to do?

goldhappywang
15th April 2009, 10:20
the QzCanvasTagItem is similar to QGraphicsItem,
QzcanvasView is similar to QGraphicsView
the zoom is similar to scale
but they don't inherit from QGraphicsView and QGraphicsItem,
drawText () ------show a rect with text but the rect don't change with the view scale

wysota
15th April 2009, 10:23
What does "similar" mean in this context? How do you use those classes?

Please use [code] tags in your posts.

goldhappywang
15th April 2009, 10:47
they are inherit from class Canvas , the QGraphicesView replace the Canvas, I want to achieve the same effect as some function in QGraphiceItem ,
I push a QPushButton the view zoom in or zoom out , but I want the Items on the view the don't zoom

wysota
15th April 2009, 11:06
As for now I have seen not a single line of code related to zooming.

goldhappywang
15th April 2009, 11:20
yes, zoom in the view ,I have finished it ,It can run,
now I want to ask for help about item,
a list of item on the view ,
for example : QGraphicsView::scale(); one item on the QGraphicsView also scale(),
I want to "QGraphicsView::scale(); one item on the QGraphicsView not scale()"
it don't related to view ,only what to do with item
do you understand?

wysota
15th April 2009, 12:07
No, I don't understand :)

goldhappywang
15th April 2009, 12:35
oh,my god!

faldzip
15th April 2009, 14:38
I'm also trying hard to understand but I failed with that... :P maybe draw your problem in ms paint or something cause your explanation is a bit messy...

wysota
15th April 2009, 17:29
I'm also trying hard to understand but I failed with that... :P maybe draw your problem in ms paint or something cause your explanation is a bit messy...

It would be enough to use full sentences with simple English terms and simple grammar. Expressing full ideas instead of expecting one to guess them helps as well.

goldhappywang
16th April 2009, 02:53
I'm sorry for the explanation .
a QGraphicisView object and a QGraphicsItem on the object ,
if QGraphicsView object scale
but the QGraphicsItem does't scale,
what to do it

wysota
16th April 2009, 06:03
I already told you at the very beginning - set ItemIgnoresTransformations flag on each of the items.