the question simple ! want this. either using qpainter class or using qt graphics framework:

there several ways using qpainterpath specified here.
here second example page:
#include <qtgui> #include <cmath> class widget : public qwidget { public: widget () : qwidget() { } private: void paintevent ( qpaintevent *) { qstring hw("hello world"); int drawwidth = width() / 100; qpainter painter(this); qpen pen = painter.pen(); pen.setwidth(drawwidth); pen.setcolor(qt::darkgreen); painter.setpen(pen); qpainterpath path(qpointf(0.0, 0.0)); qpointf c1(width()*0.2,height()*0.8); qpointf c2(width()*0.8,height()*0.2); path.cubicto(c1,c2,qpointf(width(),height())); //draw bezier curve painter.drawpath(path); //make painter ready draw chars qfont font = painter.font(); font.setpixelsize(drawwidth*2); painter.setfont(font); pen.setcolor(qt::red); painter.setpen(pen); qreal percentincrease = (qreal) 1/(hw.size()+1); qreal percent = 0; ( int = 0; < hw.size(); i++ ) { percent += percentincrease; qpointf point = path.pointatpercent(percent); qreal angle = path.angleatpercent(percent); // clockwise negative painter.save(); // move virtual origin point on curve painter.translate(point); // rotate match angle of curve // clockwise positive negate angle above painter.rotate(-angle); // draw line width above origin move text above line // , let qt transformations painter.drawtext(qpoint(0, -pen.width()),qstring(hw[i])); painter.restore(); } } }; int main(int argc, char **argv) { qapplication app(argc, argv); widget widget; widget.show(); return app.exec(); }
Comments
Post a Comment