Results 1 to 3 of 3

Thread: QVBoxLayout and QGridLayout Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Location
    My bed
    Posts
    21
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QVBoxLayout and QGridLayout Problem

    Qt Code:
    1. for(int row=0;row<4;row++)
    2. {
    3. for(int column =0;column<4;column++)
    4. {
    5. grid->addWidget(new LCDRange,row,column);
    6. }
    7. }
    8.  
    9. QVBoxLayout *layout = new QVBoxLayout;
    10. layout->addWidget(close);
    11. layout->addWidget(grid);//ERROR
    12. setLayout(layout);
    13.  
    14. ERROR = no matching function for call to ‘QVBoxLayout::addWidget(QGridLayout*&)’.candidates are: void QBoxLayout::addWidget(QWidget*, int, Qt::Alignment)
    To copy to clipboard, switch view to plain text mode 

    Could someone please tell me how to get rid of this error. Thanks.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QVBoxLayout and QGridLayout Problem

    The function name is addLayout(...) the addWidget function can add only widgets

  3. The following user says thank you to Zlatomir for this useful post:

    eLancaster (6th December 2010)

  4. #3
    Join Date
    Dec 2010
    Location
    My bed
    Posts
    21
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QVBoxLayout and QGridLayout Problem

    Thanks, that worked - but now I have another error

    QWidget::setLayout: Attempting to set QLayout "" on grid "grid", which already has a layout on the same line

Similar Threads

  1. QGridlayout problem
    By raju@123 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2010, 22:03
  2. QGridLayout problem
    By cae in forum Newbie
    Replies: 2
    Last Post: 30th November 2009, 09:53
  3. Problem with QHBoxlayout & QVBoxlayout
    By phillip_Qt in forum Qt Tools
    Replies: 5
    Last Post: 13th January 2009, 10:26
  4. QVBoxLayout and QHBoxLayout problem
    By fmariusd in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2009, 20:58
  5. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 13:01

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.