Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, August 2006
Background color for a label and goup box


Message 1 in thread

Hi,

I wanted to change the background color of a label, I tried
label->setPalette(QPalette(QColor(100,100,0),QColor(255,0,0))); but it
did'nt work.
Also, is there a way to change the  background color of the area in a group
box (which has some widgets)??

Another question is how to put hyperlinks in a label, I looked into the
QTextBrowser but it din find any good documentation on this. Please let me
know if you are familiar with solving any of these.

Thanks,
-Subir

Message 2 in thread

>I wanted to change the background color of a label, I tried
label->setPalette(QPalette(QColor
>(100,100,0),QColor(255,0,0))); but it did'nt work.
>Also, is there a way to change the  background color of the area in a group
box (which has some widgets)??

Check QPalette::setColor() functions.

For example to set the background color of a qlabel:

QPalette Pal(TheLabel->palette());
Pal.setColor(QPalette::Window, Qt::blue);
TheLabel->setPalette(Pal);

--
 [ signature omitted ] 

Message 3 in thread

Check QPalette::setColor() functions.
>
> For example to set the background color of a qlabel:
>
> QPalette Pal(TheLabel->palette());
> Pal.setColor(QPalette::Window, Qt::blue);
> TheLabel->setPalette(Pal);
>
> Yes I tried this but it had no change on my QLabel, I am using this for my
application

  QApplication MainApplication (argc, argv);
  QPalette mainAppPalette ;
  mainAppPalette.setColor
       (QPalette::Normal, QPalette::Background, Qt::white);
   mainApplication.setPalette(main_palette);

and then adding widgets with their layouts. Is it because my application is
always white, so i am not able to add colors to widgets ?? Am i doing
something wrong here??

Thanks
-Subir

Message 4 in thread


>  QApplication MainApplication (argc, argv);
>  QPalette mainAppPalette ;
>  mainAppPalette.setColor
>      (QPalette::Normal, QPalette::Background, Qt::white);
>  mainApplication.setPalette(main_palette);

>and then adding widgets with their layouts. Is it because my application is
always white, so i >am not able to add colors to widgets ?? Am i doing
something wrong here??

I've never tried setting this via the application but my
example should have included:

TheLabel->setAutoFillBackground(true)


--
 [ signature omitted ] 

Message 5 in thread

> I've never tried setting this via the application but my
> example should have included:
>
> TheLabel->setAutoFillBackground(true)


Oh ya that worked, i din see this function in any document. Thanks a lot. do
you have any idea on how to color the whole area in a Group box??

-Subir

Message 6 in thread

>Oh ya that worked, i din see this function in any document. Thanks a lot.
do you have any >idea on how to color the whole area in a Group box??

Pretty much the same way.  The "trick" is to know which roles
are required.  For example, QPalette::Window will take care
of the background of the group box.  QPalette::Button will
take care of any buttons in it.  QPalette::Base is for text
widgets background etc.

Also, there's another setColor that takes a color group and a
color role.

Look at the docs for QPalette.  Qt Assistant if pretty clear
on this.

HTH

--
 [ signature omitted ] 

Message 7 in thread

>
> Ya worked looks like group box also requires the setAutoFillBackground(true)
> to be called.
>
> My last question (hopefully for the day) is on hyperlinks. How can I use
> hyperlinks in labels, that open in the current  browser window on click, I
> looked into QTextBrowser but that din help. Let me know if you know abt this
>
>
> Thanks
> -Subir
>

Message 8 in thread

Sorry I did a reply to u rather than to the mailing list....oops

Groupbox worked looks like group box also requires the
setAutoFillBackground(true)
to be called.

My last question (hopefully for the day) is on hyperlinks. How can I use
hyperlinks in labels, that open in the current  browser window on click, I
looked into QTextBrowser but that din help. Let me know if you know abt this


Thanks
-Subir

On 8/2/06, Duane Hebert <spoo@xxxxxxxxx> wrote:
>
> >Oh ya that worked, i din see this function in any document. Thanks a lot.
> do you have any >idea on how to color the whole area in a Group box??
>
> Pretty much the same way.  The "trick" is to know which roles
> are required.  For example, QPalette::Window will take care
> of the background of the group box.  QPalette::Button will
> take care of any buttons in it.  QPalette::Base is for text
> widgets background etc.
>
> Also, there's another setColor that takes a color group and a
> color role.
>
> Look at the docs for QPalette.  Qt Assistant if pretty clear
> on this.
>
> HTH
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

Message 9 in thread

>Sorry I did a reply to u rather than to the mailing list....oops

No problem.  It should have bounced as my reply to
address isn't valid <g>

>Groupbox worked looks like group box also requires the
setAutoFillBackground(true) to be >called.

I think so.

>My last question (hopefully for the day) is on hyperlinks. How can I use
hyperlinks in labels, >that open in the current  browser window on click, I
looked into QTextBrowser but that din >help. Let me know if you know abt
this

Sorry, I can't help you there.

BTW, would you mind posting in plain text?
I seem to have to reformat your posts to reply
to them.  I'm not sure what the group guidelines
are here though.  It may also be that I'm using
OE for a newsreader.

--
 [ signature omitted ]