[Qt-interest] QGraphicsView scaled background image and fixed foreground item - is that possible?

franki franki at franki.eu.org
Mon Jun 6 16:37:13 CEST 2011


Dnia poniedziałek, 6 czerwca 2011 o 16:16:01 napisałeś:
> Simply, don't make the buttons children.Have a item group instead, with the
> background and buttons as children of the group. Continue to scale the
> background as you currently do.

But I'm not setting this buttons as a childrens of background image, actually 
what I do is:
	QPixmap pix(floorData[i].floor_pixmap); 
        floorData[i].floorItem=graphicsScene->addPixmap(pix);
        floorData[i].floorItem->hide();
        floorData[i].floorItem->setZValue(1);
        floorData[i].floorItem->setPos(0,0);
/* above is scaled background image */
/* below there is button that shouldn'y be scaled */
        floorData[i].floorButton=new QPushButton(floorData[i].name);
        floorData[i].floorButton->resize(160,50);
        floorData[i].proxyButton=graphicsScene-
>addWidget(floorData[i].floorButton);
        floorData[i].proxyButton->hide();
        floorData[i].proxyButton->resize(160,50);
        floorData[i].proxyButton->setZValue(10);
        floorData[i].proxyButton->setPos(5*(i+1)+i*floorData[i].proxyButton-
>boundingRect().width(),100);

floorItem is background image, and later on in code I have some item's that are 
children of this item, but floorButton is not. Does it have parent by default?

floorButtons are buttons that shouldn't be scaled, user can switch between 
floors images by using this buttons, and I have to display these floorButtons on 
top of the background image (whether there is part or whole of the image 
visible)

thanks
Marek

> 
> 
> 
> 
> ________________________________
> From: franki <franki at franki.eu.org>
> To: qt-interest at qt.nokia.com
> Sent: Monday, June 6, 2011 10:00 AM
> Subject: [Qt-interest] QGraphicsView scaled background image and fixed
> foreground item - is that possible?
> 
> Hi all,
> 
> Is this possible?
> I want to have background image (QGraphicsPixmapItem) with some items as a
> child items, and that will be scaled by fitInView, so the user can see
> complete image, or a part of the image if I scale to some rectangle
> (fitInView(RectF)). On the same view I need to draw some buttons (from
> time to time), eg. when user clicks external (outside from QGraphicsView)
> button, I need to draw some buttons on top of the background image, but
> regardless of the scale of background image, buttons should have the same
> fixed size, and position. Currently I draw the buttons earlier, hide them,
> and when user needs to see them I rescale, reposition, and then show them
> in QGraphicsView accordingly to the scale of the background image, but it
> would be great to draw in fixed coordinates regardless of the scale of the
> background image.
> 
> best regards
> Marek
> 
>  
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list