Archived:How to use QGroupBox in Qt
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.
Article Metadata
Tested with
Devices(s): Symbian Emulator
Compatibility
Platform(s): S60 3rd Edition FP2, S60 5th Edition
Article
Keywords: QGroupBox
Created: mind_freak
(09 Mar 2009)
Last edited: hamishwillee
(11 Oct 2012)
Contents |
Overview
A QGroupBox box is a QWidget for grouping other widgets. It provides a frame, a title and a keyboard shortcut. The title is on top, the keyboard shortcut moves keyboard focus to one of the group box's child widgets.
It is used to make a specific group of same kind or different kind of widget
QGroupBox *group=new QGroupBox();
Preconditions
- Download and install the Qt SDK
Various Function
- To set the title of QGroupBox.
group->setTitle("&Nokia Phones");
- To Align the title that is "Right,Left,center".
group->setAlignment(Qt::AlignHCenter);
- To set The layout of QGroupBox.
QVBoxLayout *layout=new QVBoxLayout(); QGroupBox *group=new QGroupBox(); group->setLayout(layout);
- To make the title checkable,So that until or unless the title checkBox value is "false" the QGroupBox is disable and if it is "true" the QGroupBox is enable
group->setCheckable(true);
Remember
- You have to first of all set the layout of the QGroupBox then after we have to add this widget in our main window.
Source Code
#include <QtGui>
#include <QApplication>
#include<Qwidget>
#include<QGroupBox>
#include<QCheckBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window=new QWidget();
QVBoxLayout *layout=new QVBoxLayout();
QVBoxLayout *layout1=new QVBoxLayout();
QGroupBox *group=new QGroupBox();
group->resize(300,300);
group->setLayout(layout);
group->setAlignment(Qt::AlignHCenter);
group->setCheckable(true);
QCheckBox *chk1=new QCheckBox("Nokia N97");
QCheckBox *chk2=new QCheckBox("Nokia E75");
QCheckBox *chk3=new QCheckBox("Nokia 5800 Xpress Music");
group->setTitle("&Nokia Phones");
layout1->addWidget(group);
layout->addWidget(chk1);
layout->addWidget(chk2);
layout->addWidget(chk3);
window->setLayout(layout1);
window->showMaximized();
window->setStyleSheet("* { background-color:rgb(150,147,88); padding: 7px ; color:rgb(255,255,255)}");
return a.exec();
}



(no comments yet)