开发者

text rendering in qt4 with different styles

say i have text is that possible to have different effects. i mean say upper half of text should have normal rendering and second half of text should have blur effect. is that possib开发者_运维百科le to achieve in qt4-c++ programming. if yes.... how. code snippet will be very useful.


I don't think there is a ready made widget for this in QT, I guess you should consider creating a custom widget and do the rendering there.

QT custom painting examples can be found here: Painting Examples

Gaussian blur algorithm description can be found here: Gaussian blur

hope this helps, regards


It depends on what you really want to do. If the type of QWidget does not matter, you could simply break the text up into two QLabels and set their fonts, sizes, whatever to be what you want (normal rendered and blurred effect in your case).

You could then use a layout to add the QLabels to a QWidget (this way they are grouped together):

QLabel label1 = new QLabel();
QLabel label2 = new QLabel();
label1.setStyleSheet(... set your stylesheets here for label1);
label2.setStyleSheet(... set your stylesheets here for label2);
QVBoxLayout layout = new QVBoxLayout();
layout.addWidget(label1);
layout.addWidget(label2);
QWidget widget = new QWidget();
widget.setLayout(layout);

This creates a widget with the two labels stacked on top of each other.

Since you say that the text is separate into two halves (upper and lower), this could be a useful solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜