[Qt-interest] How to get the application font color in Qt

Denis Akhmetzyanov dakhmetzyanov at smartlabs.tv
Wed Apr 28 13:49:58 CEST 2010


Hi,
See QPainter::setPen() method.
You could explicitly set target color:

     *QPainter paint(this);*

*     paint.setPen(Qt::red);*

*     paint.drawText(QPoint(10,30),"Duplex");*

*     *
Or use application palette:

    paint.setPen(QApplication::palette().text().color());


2010/4/28 Ramesh <ramesh.bs at robosoftin.com>

>  Hi,
>
>
>
> I want to put some text on my UI, I am drawing the text in paint event of a
> widget using  painter..
>
>
>
> Here is the sample code, which shows how I am drawing the text..
>
>
>
> *QWidget::paintEvent(painter);*
>
> *QPainter paint(this);*
>
> *paint.drawText(QPoint(10,30),"Duplex");*
>
>
>
> but, the text color is looks like the default theme color, how to set the
> application font color to the text in paint event..
>
>
>
> Thanks &regards
>
> ramesh
>
>  -----------------------------------------------
>
> Robosoft Technologies - Come home to Technology
>
> Disclaimer: This email may contain confidential material. If you were not
> an intended recipient, please notify the sender and delete all copies.
> Emails to and from our network may be logged and monitored. This email and
> its attachments are scanned for virus by our scanners and are believed to be
> safe. However, no warranty is given that this email is free of malicious
> content or virus.
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>


-- 
Best regards,
Denis Akhmetzyanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100428/01781d0e/attachment.html 


More information about the Qt-interest-old mailing list