Results 1 to 2 of 2

Thread: QgrpahicsProxyWidget: dragging and sizeing

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile QgrpahicsProxyWidget: dragging and sizeing

    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!

  2. #2
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QgrpahicsProxyWidget: dragging and sizeing

    Hi, did you ever manage to fix this? I have the same issue...

Similar Threads

  1. Replies: 11
    Last Post: 25th April 2013, 12:58
  2. built in dragging
    By idoroth in forum Newbie
    Replies: 5
    Last Post: 21st September 2011, 09:37
  3. Dragging a pointer
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2009, 03:51
  4. dragging
    By mickey in forum Newbie
    Replies: 1
    Last Post: 25th July 2006, 14:05
  5. dragging
    By mickey in forum Newbie
    Replies: 5
    Last Post: 11th March 2006, 00:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.