[Panel-devel] Fw: [Issue N193025] QGraphicsTextItem setDefaultText vs setHtml does not respect colors

Shawn Starr shawn.starr at rogers.com
Wed Jan 2 16:40:59 CET 2008


Looks like a bug in plasma ;-)

----- Forwarded Message ----
From: "qt-bugs at trolltech.com" <qt-bugs at trolltech.com>
To: shawn.starr at rogers.com
Cc: qt-bugs at trolltech.com
Sent: Wednesday, January 2, 2008 5:16:16 AM
Subject: Re: [Issue N193025] QGraphicsTextItem setDefaultText vs setHtml does not respect co lors

Hi Shawn Starr

> QGraphicsTextItem setDefaultText vs setHtml does not respect colors
>
> What I did:
> When using a QGraphicsTextItem which is inherited from KDE
> Plasma::Widgets::LineEdit
> ...
> m_labelLine->setTextInteractionFlags(Qt::TextSelectableByMouse);
> m_labelLine->setDefaultTextColor(Plasma::Theme::self()->textColor());
> m_labelLine->setDefaultText("Hello World");
>
>
>
> What I expected to see:
> I was expecting the text inside the LineEdit to show (in this case,
> white forground colour. Based on what
> Plasma::Theme::self()->textColor()) returned.
>
> What I got instead:
> Instead, I got grey forground colour for the text and when trying to
> highlight the text, I had a black colour by default and could not see
> the text being selected.
>
> More info:
> My workaround is to use setHtml which respects setDefaultTextColor.

QGraphicsTextItem does not have setDefaultText... However, the text
color is changed when I use the QGraphicsTextItem setPlainText/setHtml
so I believe this is a plasma bug. However, I'm unable to check since I
don't have it on my machine :( "going to do something about that :)"

Here is what I used to reproduce the behavior:
#include <QtGui>

int main ( int argc, char **argv )
{
    QApplication app(argc, argv);

    QGraphicsScene scene;

    QGraphicsTextItem item;
    item.setTextInteractionFlags(Qt::TextSelectableByMouse);
    item.setDefaultTextColor(Qt::red);
    item.setPlainText("Hello World");
    //item.setHtml("Hello World Html");
    item.setPos(0,0);

    scene.addItem(&item);

    QGraphicsView view;
    view.setScene(&scene);

    view.show();

    return app.exec();


}

Kind regards,
Jørgen Lind
Support Engineer
Trolltech ASA - http://www.trolltech.com






More information about the Panel-devel mailing list