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?


Qt Code:
  1. class MyWidItem : public QGraphicsProxyWidget
  2. {
  3. MyWidItem()
  4. {
  5. // doesnt work!!
  6. setFlag(QGraphicsItem::ItemIsMovable);
  7. setFlag(QGraphicsItem::ItemIsSelectable);
  8.  
  9. setWidget(new MyButtonTextWidget()); //my custom widget with 4 buttons and a lineedit
  10.  
  11. // the other problem is the sizing, see screenshot.
  12. }
  13. };
  14.  
  15.  
  16. class MyItem : public QGraphicsItem
  17. {
  18. MyWidItem()
  19. {
  20. // perfectly fine!
  21. setFlag(QGraphicsItem::ItemIsMovable);
  22. setFlag(QGraphicsItem::ItemIsSelectable);
  23. }
  24. };
  25.  
  26.  
  27. i then add my MyWidItem to the scene like this:
  28.  
  29.  
  30. //...
  31. MyWidItem *item = new MyWidItem();
  32. thescene->addItem(item); //add an itme to the graphicsscene
  33. itemvector.append(item); //custom stuff
  34. //...
To copy to clipboard, switch view to plain text mode 



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


grapherror.PNG


any help is appreciated!