views:

60

answers:

1

Hi, I am trying to make a widget in such a way that when ever I typed in a lineedit, and click OK button, then that word must come with some visual effects(like with different font style and background color). After that, if I again type another word and clicked the OK, it should come after the first one, like this it can grow further. If there are so many words, then the above things should be shown in a window with horizontal,vertical bars. So by dragging the bars, I should be able to see all the words. I am currently doing this by drawing the text into a pixImage, and showing it using QLabel. For vertical & horizontal bar, I am putting all these labels inside a QScroll Area. But I am getting error.

Can anybody suggest what to do, or how to achieve this effect?

+1  A: 

You can use html formatting with a QLabel. This example sets 100 lines of formatted text to a QLabel:

QString line = "<b>This</b> is <font color=\"red\">red</font> text<br>";
QString text;
for (int i = 0; i < 100; ++i)
    text += line;
ui->label->setText(text);

Then add that QLabel to a QScrollArea with a vertical box layout and ... you are done.

Roku
@Roku I am not adding the text, I am making the text as a image then I am using label->setPixImage(image). Then only I can achieve too many visual effects . But anyway your trick is awesome. Thank you for it.
prabhakaran