Results 1 to 6 of 6

Thread: QGraphicsWidget Position Promble

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question QGraphicsWidget Position Promble

    Hi, everyone,

    I want to implement a custom QGraphicsLayout that works in the following manner.The item added to the custom layout can be position absolutely by call setpos() function. I don't want to use QGraphicsAnchorLayout, QGraphicsGridLayout, and QGraphicsLinearLayout, because when the item was added to the common layout, setpos() function not work.

    Or Is there method after the item was added to the common layout , i still can move the item's anywhere within the parent coordinate?

    ...
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
    layout->setContentsMargins(25,25,25,25);
    layout->setMinimumSize(603,368);

    layout->addItem(proxyForName["helpBtn"]);
    proxyForName["helpBtn"]->setPos(100,100); -> not work
    setLayout(layout);
    ...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsWidget Position Promble

    If the item is in a layout then you can't change its position because it would break the layout.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsWidget Position Promble

    Is any other way i can work around? I want to put a QGraphicsWidget into the other QGraphicsWidget, the fronter widget locate above the later, so i want to know is any method position the fronter one absolutly within the later widget's coordinate, other than binding to layout.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsWidget Position Promble

    Quote Originally Posted by weihao.ma View Post
    Is any other way i can work around?
    You can just not use layouts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsWidget Position Promble

    If i just not use layout, how can i put QGraphicsWidget into another QGraphicsWidget, QGraphicsWidget doesn't supports the api, but addLayout() api is available.

  6. #6
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsWidget Position Promble

    give a parent during construction or use QGraphicsItem::setParentItem.

Similar Threads

  1. Qml in QGraphicsWidget
    By animagani in forum Qt Quick
    Replies: 7
    Last Post: 2nd December 2010, 16:20
  2. Replies: 0
    Last Post: 3rd February 2010, 13:38
  3. QGraphicsWidget and ItemIsMovable()
    By paolom in forum Qt Programming
    Replies: 8
    Last Post: 20th October 2009, 13:25
  4. QTextEdit on a QGraphicsWidget
    By paolom in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2009, 14:08
  5. Positioning QGraphicsWidget
    By jasper_ferrer in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2009, 14:34

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.