PDA

View Full Version : QgrpahicsProxyWidget: dragging and sizeing



tuli
20th September 2013, 16:33
Hi,

i am working on graphics-scene, which currently adds a QGrpahicsItems subclass and does some custom drawing in the pain() event. This works fine, but now i#d like to add a custom widget, consisting of 4 child-widgets. I derive from QGraphicsProxyWidget (instead of QGraphicsItem) and add my widget, before putting it on the scene. There are just two problems with that:

1) i cant drag the item around anymore, despite QGraphicsItem::ItemIsMovable. i suspect this is because my widget "steals" the input. How can i pass the events "up"?
2) and more importantly, the widget is not properly sized. See the screenshot attached. When i apply some exotic kungfu, which sets the size of item to a value bigger than the size of the widget, the
widget is shown (with a large margin). So i suppose the question is how can i communicate the size as reported by the layout of the custom widget to the coating QGraphicsProxyWidget?



class MyWidItem : public QGraphicsProxyWidget
{
MyWidItem()
{
// doesnt work!!
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);

setWidget(new MyButtonTextWidget()); //my custom widget with 4 buttons and a lineedit

// the other problem is the sizing, see screenshot.
}
};


class MyItem : public QGraphicsItem
{
MyWidItem()
{
// perfectly fine!
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
}
};


i then add my MyWidItem to the scene like this:


//...
MyWidItem *item = new MyWidItem();
thescene->addItem(item); //add an itme to the graphicsscene
itemvector.append(item); //custom stuff
//...



here is the real widget and how it is displayed on the scene:


9616


any help is appreciated!

papillon
23rd April 2014, 23:49
Hi, did you ever manage to fix this? I have the same issue...