Results 1 to 5 of 5

Thread: Problems putting layouts inside groupbox

  1. #1
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Problems putting layouts inside groupbox

    Hello!
    I have some code. It creates several objects and than put them in layouts. Layouts are created as a child of groupbox. But after compilation layouts with elements in it doesn't show. Only QProgressBar and QTextEdit show because they are not placed in layouts.
    Qt Code:
    1. void GUI::createObjects()
    2. {
    3. kdebugf();
    4.  
    5. editBox = new QGroupBox(1,Qt::Horizontal,tr("Message Data (max 2000 chars)"),this);
    6. spinsBox = new QGroupBox(1,Qt::Horizontal,tr("Messages Options"),this);
    7. progressBox = new QGroupBox(1,Qt::Horizontal,tr("Progress"),this);
    8. buttonsBox = new QGroupBox(1,Qt::Horizontal,this);
    9.  
    10.  
    11. labelAmount = new QLabel(tr("Messages Amount:"), this);
    12. labelDelay = new QLabel(tr("Messages Delay (msecs):"), this);
    13. labelStep = new QLabel(tr("Sent message <b>0</b> from <b>0</b>"),this);
    14.  
    15. messageData = new QTextEdit(editBox);
    16. messagesAmount = new QSpinBox(this);
    17. messagesDelay = new QSpinBox(this);
    18.  
    19. messagesAmount->setMinValue(1);
    20. messagesDelay->setMaxValue(9999999);
    21. messagesAmount->setMaxValue(9999999);
    22.  
    23. progressBar = new QProgressBar(progressBox);
    24.  
    25. Cancel = new QPushButton(tr("Close"), this);
    26. Reset = new QPushButton("Reset", this);
    27. Go = new QPushButton(tr("Go"), this);
    28.  
    29. Go->setDefault(true);
    30. Go->setEnabled(false);
    31.  
    32. mainLayout = new QVBoxLayout(this);
    33. amountLayout = new QHBoxLayout;
    34. delayLayout = new QHBoxLayout;
    35. spinsLayout = new QVBoxLayout(spinsBox);
    36. buttonsLayout = new QHBoxLayout(buttonsBox);
    37.  
    38. kdebugf2();
    39. }
    40.  
    41. void GUI::layoutsInOrder()
    42. {
    43. kdebugf()
    44.  
    45. amountLayout->addWidget(labelAmount);
    46. amountLayout->addWidget(messagesAmount);
    47.  
    48. delayLayout->addWidget(labelDelay);
    49. delayLayout->addWidget(messagesDelay);
    50.  
    51. spinsLayout->addLayout(amountLayout);
    52. spinsLayout->addLayout(delayLayout);
    53.  
    54. buttonsLayout->addWidget(Go);
    55. buttonsLayout->addWidget(Cancel);
    56. buttonsLayout->addWidget(Reset);
    57.  
    58. mainLayout->addWidget(editBox);
    59. mainLayout->addWidget(spinsBox);
    60. mainLayout->addWidget(buttonsBox);
    61. mainLayout->addWidget(progressBox);
    62.  
    63. spinsLayout->setSpacing(10);
    64. buttonsLayout->setSpacing(3);
    65. mainLayout->setMargin(11);
    66. mainLayout->setSpacing(2);
    67.  
    68. kdebugf2();
    To copy to clipboard, switch view to plain text mode 
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Problems putting layouts inside groupbox

    IMHO you also must create PARENT layout and add to it your layouts.
    Also why you create visual alements manually? It more easy create it by QDesigner and then you not be have alike this questions
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Re: Problems putting layouts inside groupbox

    There is parent layout and it is called mainLayout. I think problem is here:
    spinsLayout = new QVBoxLayout(spinsBox);
    buttonsLayout = new QHBoxLayout(buttonsBox);

    here I create layouts with qgroupbox as a parent. I receive warnigns that tells me that qgroupbox already has a layout. But what if I want to put some layout (with some objects in order inside it) inside a groupbox. Please help.

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Problems putting layouts inside groupbox

    Quote Originally Posted by conexion2000
    There is parent layout and it is called mainLayout. I think problem is here:
    actually its not main layout . Under main layout i mean form layout that will be parent for your layouts. But i also think that problem ist no here.

    Quote Originally Posted by conexion2000
    I receive warnigns that tells me that qgroupbox already has a layout. But what if I want to put some layout (with some objects in order inside it) inside a groupbox. Please help.
    Listen your warnings
    I think its the same if you add objects in group box without layout.
    Play arround it.
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Re: Problems putting layouts inside groupbox

    But the problem is that I want to put some group of widgets horizontally, then these group vertically. If I do that using QGroupBox I will have 4 outlined boxes not 1.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.