PDA

View Full Version : multiple columns qtextdocument



xyfix
24th September 2009, 09:36
hi,

i need some help creating a multi column rich text editor ( like in the news paper articles). I have tried it with QTextEditor and QTextDocument and QTextFrames, but I don't know if this is the right track. A small part of my code where I want to set up the multi column stuff.



QPrinter printer;
QTextDocument *doc = textEdit->document();
QTextCharFormat txt_frm;
QTextCursor cur( doc );
QTextFrameFormat frame_frm;

printer.setPaperSize( QPrinter::A4 );

doc->setPageSize( printer.pageRect().size() );
doc->setTextWidth( printer.pageRect().width());

frame_frm.setWidth( qreal( 105 ));
frame_frm.setHeight( qreal( 297));

cur.beginEditBlock();
cur.insertFrame( frame_frm );

QFile file( QString("./test.txt" ));

if( file.open( QFile::ReadOnly ))
{
QTextStream stream( &file );
cur.insertText( stream.readAll(), txt_frm );
}