Results 1 to 5 of 5

Thread: Embedded widgets size

  1. #1
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Question Embedded widgets size

    Hello!

    If I place widgets in QGraphicsView, they don't fits its size:

    Qt Code:
    1. // Add table in the scene
    2. QGraphicsGridLayout *grid = new QGraphicsGridLayout();
    3. grid->addItem(scene->addWidget(tableWidget), 0, 0);
    4.  
    5. QGraphicsProxyWidget* form = new QGraphicsProxyWidget;
    6. form->setLayout(grid);
    7. form->setCacheMode(QGraphicsItem::ItemCoordinateCache);
    8.  
    9. scene->addItem(form);
    To copy to clipboard, switch view to plain text mode 

    In the example above there is table in the scene, and if scene will be set to QGraphicsView, the table doesn't fit size according to the size of QGraphicsView.

    That's the point. ^) Does anybody come across with such a problem?

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Embedded widgets size

    Try if QGraphicsItem::ensureVisible helps you

  3. #3
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Embedded widgets size

    Unfortunately, it has no effect. Either I call it with QRect or passing my QWidgetItem (which is QGraphicsProxyWidget containig QGraphicsGridLayout and QWidgetTable).

    I always get:


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

    Default Re: Embedded widgets size

    Quote Originally Posted by Indalo View Post
    In the example above there is table in the scene, and if scene will be set to QGraphicsView, the table doesn't fit size according to the size of QGraphicsView.
    Why would it? The item won't adjust to the size of the scene (or the view) by itself. You have to reimplement the views resizeEvent(), resize the scene and modify geometry of the item containing 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.


  5. #5
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Embedded widgets size

    wysota, thanks. Could you explain a little bit more exactly? As I got, firstly I have to reimplement QGraphicsView::resizeEvent(). There I would change size of the scene to the new size of QGraphicsView. And then...? I need to call setGeometry to every item in the scene? But how could I calculate new sizes of item? By "hand" or what?

Similar Threads

  1. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 16:13
  2. Using Qt4 Embedded widgets in Qt3
    By kobleh in forum Qt Programming
    Replies: 3
    Last Post: 27th April 2009, 19:00
  3. Embedded Widgets Demos
    By jhowland in forum Qt Programming
    Replies: 1
    Last Post: 15th January 2009, 11:53
  4. Replies: 1
    Last Post: 27th March 2008, 15:10
  5. Replies: 4
    Last Post: 10th December 2006, 09:04

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
  •  
Qt is a trademark of The Qt Company.