#include <QtGui>
{
//Q_OBJECT;
public:
{
setPlainText ( "human ");
f.setPixelSize(40);
setFont(f);
rotate(-90);
}
{
}
{
// Isn't this strange to call update in paint event ?
//update();
painter->setPen(Qt::black);
painter->drawRect(boundingRect());
}
};
int main(int argc, char *argv[])
{
FloatText t(&scene);
t.setPos(500,500);
view.show();
return app.exec();
}
#include <QtGui>
class FloatText : public QGraphicsTextItem
{
//Q_OBJECT;
public:
FloatText( QGraphicsScene *scene )
: QGraphicsTextItem(0, scene)
{
setPlainText ( "human ");
QFont f = font();
f.setPixelSize(40);
setFont(f);
rotate(-90);
setFlags(QGraphicsItem::ItemIsMovable);
}
QRectF boundingRect() const
{
return QGraphicsTextItem::boundingRect().adjusted(-2,-2,+2,+2);
}
void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
{
QGraphicsTextItem::paint(painter,option,widget);
// Isn't this strange to call update in paint event ?
//update();
painter->setPen(Qt::black);
painter->drawRect(boundingRect());
}
};
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QGraphicsScene scene(0,0,1024,768);
FloatText t(&scene);
t.setPos(500,500);
QGraphicsView view(&scene);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks