Results 1 to 4 of 4

Thread: group box

  1. #1
    Join Date
    Jul 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default group box

    I have tried hard to add a group box to the following set of widgets but failed, can someone point out a mistake!!

    Qt Code:
    1. QLabel *labelSA = new QLabel("Self Analysis Tools");
    2. QComboBox *comboBoxSA = new QComboBox(this);
    3. // code
    4. QLabel *labelST = new QLabel("Slope Threshold for Feature Peeling");
    5. QSlider *sliderST = new QSlider(Qt::Horizontal);
    6. // code
    7. QLabel *labelMDFP = new QLabel("Min diff for FP b/w local min and local max");
    8. QSlider *sliderMDFP = new QSlider(Qt::Horizontal);
    9. // code
    10. QLabel *labelID = new QLabel("Inter-DS Analysis");
    11. QComboBox *comboBoxID = new QComboBox(this);
    12. // code
    13. QLabel *labelCT = new QLabel("Clamp Threshold for Inter-DS width difference");
    14. QSlider *sliderCT = new QSlider(Qt::Horizontal);
    15. // code
    16. QLabel *labelZI = new QLabel("Zoom In/Out from CT Dataset");
    17. QPushButton *buttonRC = new QPushButton("Reset Control Points");
    18. // code
    19. QPushButton *buttonZI = new QPushButton("Zoom In/Out");
    20. // code
    21.  
    22. // a group box starting here
    23.  
    24. QVBoxLayout *vbox0 = new QVBoxLayout;
    25. vbox0->addWidget(labelSA, 0, Qt::AlignTop);
    26. vbox0->addWidget(comboBoxSA, 0, Qt::AlignTop);
    27. vbox0->addWidget(labelST, 0, Qt::AlignTop);
    28. vbox0->addWidget(sliderST, 0, Qt::AlignTop);
    29. vbox0->addWidget(labelMDFP, 0, Qt::AlignTop);
    30. vbox0->addWidget(sliderMDFP, 0, Qt::AlignTop);
    31. // a group box starting here
    32. vbox0->addWidget(labelID, 0, Qt::AlignTop);
    33. vbox0->addWidget(comboBoxID, 0, Qt::AlignTop);
    34. vbox0->addWidget(labelCT, 0, Qt::AlignTop);
    35. vbox0->addWidget(sliderCT, 0, Qt::AlignTop);
    36. // a group box starting here
    37. vbox0->addWidget(labelZI, 0, Qt::AlignTop);
    38. vbox0->addWidget(buttonRC, 0, Qt::AlignTop);
    39. vbox0->addWidget(buttonZI, 0, Qt::AlignTop);
    40. vbox0->addStretch(1);
    41.  
    42. QWidget *toolpage0 = new QWidget;
    43. toolpage0->setLayout(vbox0);
    44.  
    45. toolbox->addItem(toolpage0, "Automatic Analysis of Datasets");
    To copy to clipboard, switch view to plain text mode 

    i tried to get help from the QT assistant but i get a run time error at the last line it seems as if i cannot have a group box and toolpage at the same time.

    help needed

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: group box

    And what is the problem? It should be as easy as:
    Qt Code:
    1. QWidget *toolpage0 = new QWidget(toolbox);
    2. QGroupBox *box0 = new QGroupBox(toolpage0);
    3. QVBoxLayout *vbox0 = new QVBoxLayout(box0);
    4. vbox0->addWidget(labelSA, 0, Qt::AlignTop);
    5. vbox0->addWidget(comboBoxSA, 0, Qt::AlignTop);
    6. vbox0->addWidget(labelST, 0, Qt::AlignTop);
    7. vbox0->addWidget(sliderST, 0, Qt::AlignTop);
    8. vbox0->addWidget(labelMDFP, 0, Qt::AlignTop);
    9. vbox0->addWidget(sliderMDFP, 0, Qt::AlignTop);
    10. box0->setLayout(vbox0);
    11.  
    12. QVBoxLayout *toolLayout = new QVBoxLayout(toolpage0);
    13. toolLayout->addWidget(box0);
    14. toolPage0->setLayout(toolLayout);
    15.  
    16. toolbox->addItem(toolpage0, "Automatic Analysis of Datasets");
    To copy to clipboard, switch view to plain text mode 


    More or less .

    Regards

  3. #3
    Join Date
    Jul 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: group box

    thanks for help

    I was not handling the toolpage0 correctly, am a QT novoice

    one more query:
    1. my group boxes occupy the entire area rather then doing some kinda minimum area occupation. for instance, if I have two group boxes, they divide the entire available area between them. there is a lot of empty space within the group boxes as well. How can I keep the size of the group boxes to the minimum required.

    best wishes

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: group box

    In Qt Designer you would add a spacer item, in code QBoxLayout::addStretch() is fine.
    J-P Nurmi

Similar Threads

  1. GraphicsView: Notifying geometry change to parent group
    By Gopala Krishna in forum Qt Programming
    Replies: 8
    Last Post: 12th August 2007, 12:04
  2. Suggestions for collapsible group boxes?
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2007, 19:52
  3. No action checked in an exclusive action group
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 13th February 2006, 06:19
  4. How to add a Action Group?
    By hcostelha in forum Qt Tools
    Replies: 2
    Last Post: 18th January 2006, 17:25
  5. insert a widget into a group "on-the-fly"
    By soul_rebel in forum Qt Programming
    Replies: 4
    Last Post: 15th January 2006, 00:29

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.