×
Namespaces

Variants
Actions

Archived:How to use QGroupBox in Qt

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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.

Article Metadata
Tested with
Devices(s): Symbian Emulator
Compatibility
Platform(s): S60 3rd Edition FP2, S60 5th Edition
Symbian
S60 5th Edition
S60 3rd Edition FP2
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();

GorupBox.JPG

Preconditions

  • Download and install the Qt SDK

Various Function

  • To set the title of QGroupBox.
group->setTitle("&Nokia Phones");

GorupBox.JPG

  • To Align the title that is "Right,Left,center".
group->setAlignment(Qt::AlignHCenter);

Group003.JPG

  • 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);


Group002.JPG


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();
}


ScreenShot

Group001.jpg

This page was last modified on 11 October 2012, at 04:14.
161 page views in the last 30 days.
×