Results 1 to 3 of 3

Thread: QGridlayout problem

  1. #1
    Join Date
    Sep 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default QGridlayout problem

    Hi,

    I am new to Qt. I am developing simple application using Qridlayout. I am not able to add the groupbox in gridlayout as sepecified position.

    QGridlayout * layout = new QGridlayout()
    layout->addWidget(qroupBox,2,1);
    setLayout(layout);

    Pbm is Qroupbox is adding in the gridlayout at posistion(0,0) not in (2,1)

    can you tell me how to solve this issue?

    Regards,
    Raju

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGridlayout problem

    Quote Originally Posted by raju@123 View Post
    Pbm is Qroupbox is adding in the gridlayout at posistion(0,0) not in (2,1)
    No, that is not true! It is at (2,1) but you don't check it right. You probably look at the screen where it appears at (0,0) but that is because all other rows and columns are empty and so (2,1) acquires their space. See the output of:
    Qt Code:
    1. QLabel l("foo");
    2. gl.addWidget(&l, 2, 1);
    3. qDebug() << "rows" << gl.rowCount();
    4. qDebug() << "cols" << gl.columnCount();
    5. if (gl.itemAtPosition(2, 1))
    6. {
    7. qDebug() << "Item at (2,1)" << gl.itemAtPosition(2, 1);
    8. qDebug() << " -" << gl.itemAtPosition(2, 1)->widget();
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGridlayout problem

    you could place for example empty labels on position (0,0), (0,1) and so on to solve this issue

    this would look like this:
    Qt Code:
    1. QLabel *label = new QLabel("");
    2. QGridLayout *layout = new QGridLayout();
    3. layout->addWidget(label,0,0,2,1);
    4. layout->addWidget(yourGroupBox,2,1);
    5. //add some additional label to place your groupbox at 2,1 (wherever this might be)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGridLayout problem
    By cae in forum Newbie
    Replies: 2
    Last Post: 30th November 2009, 09:53
  2. QGridLayOut
    By Rakesh_Kumar in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 04:49
  3. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 13:01
  4. Qt 3.3 QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2007, 17:40
  5. QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 29th June 2006, 20: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
  •  
Qt is a trademark of The Qt Company.