MyRichText::MyRichText( QWidget *parent, const char *name ) : QVBox( parent, name ) { setMargin( 5 ); view = new QTextView( this ); view->setText( "This is a <b>Test</b> with <i>italic</i> <u>stuff</u>" ); QBrush paper; paper.setPixmap( QPixmap( "../richtext/marble.png" ) ); if ( paper.pixmap() != 0 ) view->setPaper( paper ); else view->setPaper( white ); view->setText( sayings[0] ); view->setMinimumSize( 450, 250 ); QHBox *buttons = new QHBox( this ); buttons->setMargin( 5 ); bClose = new QPushButton( "&Close", buttons ); bPrev = new QPushButton( "<< &Prev", buttons ); bNext = new QPushButton( "&Next >>", buttons ); bPrev->setEnabled( FALSE ); connect( bClose, SIGNAL( clicked() ), qApp, SLOT( quit() ) ); connect( bPrev, SIGNAL( clicked() ), this, SLOT( prev() ) ); connect( bNext, SIGNAL( clicked() ), this, SLOT( next() ) ); num = 0; }
bool readBrushNode( const QDomElement& element, QBrush& brush ) { bool ok = true; QColor tempColor; Qt::BrushStyle tempStyle; QPixmap tempPixmap; QDomNode node = element.firstChild(); while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "Color" ) { ok = ok & readColorNode( element, tempColor ); } else if( tagName == "Style" ) { QString value; ok = ok & readStringNode( element, value ); tempStyle = stringToBrushStyle( value ); } else if( tagName == "Pixmap" ) { ok = ok & readPixmapNode( element, tempPixmap ); } else { qDebug( "Unknown tag in brush" ); } } node = node.nextSibling(); } if( ok ) { brush.setColor( tempColor ); brush.setStyle( tempStyle ); if( !tempPixmap.isNull() ) brush.setPixmap( tempPixmap ); } return ok; }