PDA

View Full Version : query w.r.t QGroupBox



nupul
2nd May 2006, 19:13
How do i get the group box title in a larger font and a different color?

How do I change the color/thickness etc of the group box frame?

Thanks

Nupul

munna
2nd May 2006, 19:31
How do i get the group box title in a larger font and a different color?

I think the title box is a label, so you can use rich text and change the font and color.


How do I change the color/thickness etc of the group box frame?

For this I think you will have to use QStyle.

nupul
3rd May 2006, 18:40
This is what i did....

Group box is a widget so I set it's palette and I could get a different frame color.
Now the thing is this....The Widget Window's text is set to white and that of the Group box is set to Dark-Yellow. If I change the color of the group box to white....all the window text defaults to black!!! :confused: Could anyone explain what is wrong!!!

Thanks

Nupul

georgie
4th May 2006, 05:35
can you show us some code?

nupul
4th May 2006, 07:44
sure...here's the code...



MyMenuLayout::MyMenuLayout(QWidget *parent) : QWidget(parent)
{
main_layout = new QHBoxLayout;

v_right = new QVBoxLayout;
v_middle = new QVBoxLayout;
v_left = new QVBoxLayout;

grpbox_right = new QGroupBox();
grpbox_middle = new QGroupBox();
grpbox_left = new QGroupBox();

buttongrp_right = new QButtonGroup(grpbox_right);
buttongrp_middle = new QButtonGroup(grpbox_middle);
buttongrp_left = new QButtonGroup(grpbox_left);

connect(buttongrp_left,SIGNAL(buttonClicked(int)), this,SLOT(leftGroupButtonClicked(int)));
connect(buttongrp_middle,SIGNAL(buttonClicked(int) ),this,SLOT(middleGroupButtonClicked(int)));
connect(buttongrp_right,SIGNAL(buttonClicked(int)) ,this,SLOT(rightGroupButtonClicked(int)));

//Set layout margins and inter-widget spacing.

v_right->setMargin(2);
v_right->setSpacing(3);

v_left->setMargin(2);
v_left->setSpacing(3);

v_middle->setMargin(2);
v_middle->setSpacing(3);

//set group box flat for a particular effect.

grpbox_right->setFlat(true);
grpbox_left->setFlat(true);
grpbox_middle->setFlat(true);

//set a different frame color for the group boxes

grpbox_right->setPalette(QPalette(Qt::darkYellow));
grpbox_left->setPalette(QPalette(Qt::darkYellow));
grpbox_middle->setPalette(QPalette(Qt::darkYellow));


// setWindowFlags(Qt::SubWindow|Qt::FramelessWindowHi nt);
setWindowTitle("My Menu!");

setFont(QFont("Helvetica", 12, QFont::Bold));

setGeometry(50,50,900,500);

setMenuBackground();

}

void MyMenuLayout::setMenuBackground()
{
//read background image

QSettings bg_settings("./mymenu.background",QSettings::IniFormat);
bg_settings.beginGroup("Menu Background");

QString bg_image = bg_settings.value("menu_bg_img").toString();

palette = QWidget::palette();

//set bg image and button/window colors.

brush = QPixmap(bg_image);
palette.setBrush(QPalette::Window,brush);
palette.setBrush(QPalette::ButtonText, Qt::white);
palette.setBrush(QPalette::Button, Qt::darkBlue);
palette.setBrush(QPalette::WindowText, Qt::white);
setPalette(palette);


}

zlatko
4th May 2006, 07:56
This thread can be helpful (http://www.qtcentre.org/forum/showthread.php?t=2015)