drawtext.h
#ifndef _DRAWTEXT_H_
#define _DRAWTEXT_H_
#include <QWidget>
#include <QPixmap>
class DrawText : public QWidget
{
public:
DrawText( QWidget * = 0 );
protected:
void paintEvent( QPaintEvent * );
private:
int randomInt( int );
int randomInt( int , int );
QPixmap pixmap;
};
#endif
drawtext.cpp
#include "drawtext.h"
#include <QtGui>
#include <cstdlib>
DrawText::DrawText( QWidget *parent )
:QWidget( parent )
{
const int WIDTH = 800;
const int HEIGHT = 600;
const int MAX_FONT_SIZE = WIDTH / 4;
const int MIN_FONT_SIZE = WIDTH / 40;
pixmap = QPixmap( QSize( WIDTH, HEIGHT ) );
pixmap.fill( Qt::white );
QPainter painter( &pixmap );
painter.setRenderHint( QPainter::Antialiasing );
sran