PDA

View Full Version : Hi everyone



Ahmad
31st May 2007, 08:58
i have two questions:
first how can i apply html text formatting to a string variable , i mean i have some thing like this
titreLabel = new QLabel("<font color= 'green' size = 15><b>Welcome</b></font>" + surname + " " + name, this);

my formating applies only to welcome but i dont know how i can apply the same formatting the strings contained in my two variables surname and name... cause if i put then between " " they will not be considered as variables..

the second question is that how can i put an image on the background of a widget

tnx for ur help...

wysota
31st May 2007, 09:10
my formating applies only to welcome but i dont know how i can apply the same formatting the strings contained in my two variables surname and name... cause if i put then between " " they will not be considered as variables..

titreLabel = new QLabel(
QString("<font color= 'green' size = "15"><b>Welcome %1 %2").arg(surname).arg(name),
this);


the second question is that how can i put an image on the background of a widget

Set the image as a brush for the background role of your widget's palette.

Ahmad
31st May 2007, 10:33
QPalette palette;
palette->setBrush(QPalette::Background,QBrush(Qt::blue,Qt:: SolidPattern));
this->setPalette(palette);

i have written this, but i see just a blue sceen splashes and then disappears, i dont really know how to set my background color that should not disappear :confused:

wysota
31st May 2007, 11:30
First of all don't create a new palette but fetch it from the widget you are changing. Second of all, maybe you used the incorrect role for the widget (what widget is that?), third of all, if you're styling a custom widget, it might not support using a palette to paint its background.