准备画一个音符的符尾,首先用TrueType程序在E000处画出了一个符尾,然后用以下代码实现:
#include <QtGui>
#include <QTextCodec>
#include <QHash>
#include <QList>
#include<QString>
#include<QPainter>
#include <QRect>
#include<QPoint>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPixmap *p= new QPixmap(1000,1000);
p->fill(Qt::white);
QPainter *painter = new QPainter(p);
painter->setPen(QPen(Qt::black, 0));
painter->setFont(QFont("Times New Roman"));
painter->save();
painter->setFont(QFont("全部",30));
QString str;
str.resize(1);
str[0]=QChar(0xee000);
painter->drawText(150,150,str);
painter->drawLine(1,1,50,50);
painter->restore();
p->save("chole.png","PNG");
return a.exec();
}
生成的图片有直线,但是却始终画不出符尾来,特此请教大虾