Results 1 to 6 of 6

Thread: Adding QGraphicsView to QVBoxLayout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Adding QGraphicsView to QVBoxLayout

    Hello,
    I've got an application in which I'm trying to display something in a graphics view on a button click in a mainwindow.cpp file.
    I've looked at several examples, and many of them seem to be doing such with using something along the lines of

    layout->addWidget( view );

    where layout is a defined QVBoxLayout, or QHBoxLayout, and view is a QGraphicsView they've defined.
    This is definitely not working for me, and I have no idea why.
    Any help would be greatly appreciated.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Adding QGraphicsView to QVBoxLayout

    What are you doing with the layout after adding QGraphicsView ? You need to set it on a widget:
    Qt Code:
    1. QLayout * layout = new QVBoxLayout();
    2. layout->addWidget(view);
    3. QWidget * w = new QWidget();
    4. w->setLayout(layout);
    5. w->show();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding QGraphicsView to QVBoxLayout

    This completely solved my problem.
    Thanks a lot!

Similar Threads

  1. QVBoxLayout to center
    By seltra in forum Newbie
    Replies: 2
    Last Post: 7th October 2010, 18:23
  2. QHBoxLayout & QVBoxLayout
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2010, 14:13
  3. QGraphicsView and adding QWidget with transparent areas
    By sting73 in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2009, 11:19
  4. QScrollView with a QVboxlayout
    By rishid in forum Newbie
    Replies: 1
    Last Post: 18th January 2008, 16:14
  5. Adding widgets to a QGraphicsView's margins
    By nmather in forum Qt Programming
    Replies: 2
    Last Post: 7th April 2007, 16:52

Tags for this Thread

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.