Results 1 to 4 of 4

Thread: QGraphicsLinearLayout does not behave like QVBoxLayout

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsLinearLayout does not behave like QVBoxLayout

    The left side(QGraphicsView,QGraphicsLinearLayout based)of the window should behave like the right side(QWidget,QVBoxLayout based) of the window.
    This means QTreeWidget and QPushBotton should fill the whole area of QGraphicsView. Also if the window is resized.

    Any ideas how to fix this code? Or is there a complete different way?

    Qt Code:
    1. GraphicWidgetTest::GraphicWidgetTest(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ui.setupUi(this);
    5.  
    6. // left side
    7. QGraphicsView *view = new QGraphicsView(ui.centralWidget);
    8. view->setScene(scene);
    9.  
    10. //scene->setBackgroundBrush(QBrush(QColor(Qt::red)));
    11. QGraphicsLinearLayout *vboxl = new QGraphicsLinearLayout;
    12. vboxl->setOrientation(Qt::Vertical);
    13. vboxl->addItem(scene->addWidget(new QTreeWidget));
    14. vboxl->addItem(scene->addWidget(new QPushButton("buttonl")));
    15.  
    16. QGraphicsWidget *form = new QGraphicsWidget;
    17. form->setLayout(vboxl);
    18. scene->addItem(form);
    19.  
    20. // right side
    21. QWidget *right = new QWidget(ui.centralWidget);
    22. QVBoxLayout *vboxr = new QVBoxLayout;
    23. vboxr->addWidget(new QTreeWidget);
    24. vboxr->addWidget(new QPushButton("buttonr"));
    25. right->setLayout(vboxr);
    26.  
    27. //
    28. QHBoxLayout *hbox = new QHBoxLayout;
    29. hbox->addWidget(view);
    30. hbox->addWidget(right);
    31.  
    32. ui.centralWidget->setLayout(hbox);
    33. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 5th September 2009 at 11:52.

Similar Threads

  1. QVBoxLayout width size limit
    By QPlace in forum Qt Programming
    Replies: 7
    Last Post: 18th June 2009, 16:41
  2. Disable QVBoxLayout Border
    By Qt Coder in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2009, 12:50
  3. QVBoxLayout and QHBoxLayout problem
    By fmariusd in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2009, 20:58
  4. Inconsistent behaviour of QVBoxLayout
    By spraff in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2008, 18:36
  5. Custom Widget inside a QVboxLayout
    By nemesis in forum Qt Programming
    Replies: 5
    Last Post: 25th June 2008, 14:55

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.