QTextFrame Abstände [gelöst]
Verfasst: 23. September 2008 21:01
Hallo,
ich versuche in Abhängigkeit einer Enum Text einen QTextDocument/QTextEdit einzufügen:
und in main() testweise:
Klappt soweit recht gut, allerdings ist ein RIESEN Platz schwischen den Frames. Ich habe noch nicht die Stelle gefunden, diesen weg zu bekommen. Über den root frame geht's wohl nicht. Wie geht das? So sieht es aus:
http://img159.imageshack.us/done.php?l= ... nntrd5.png
Grüße
Olaf
ich versuche in Abhängigkeit einer Enum Text einen QTextDocument/QTextEdit einzufügen:
Code: Alles auswählen
class QED : public QTextEdit
{
...
enum RegionType {
Plain,
Edit,
Input,
Output,
Error,
Warning
};
QED::QED()
{
QTextFrame *topFrame = document()->rootFrame();
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
topFrameFormat.setBorder(1);
topFrameFormat.setMargin(1);
topFrameFormat.setPadding(1);
topFrame->setFrameFormat(topFrameFormat);
}
void QED::write( const QString& txt, RegionType region )
{
QTextFrame *topFrame = document()->rootFrame();
QTextCursor cursor(this->textCursor());
cursor.setPosition(topFrame->lastPosition());
QTextCharFormat textFormat;
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
QTextFrameFormat frameFormat;
frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
frameFormat.setBorder(1);
frameFormat.setMargin(1);
frameFormat.setPadding(1);
switch( region ) {
case Edit:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, textFormat);
break;
case Input:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, textFormat);
break;
case Output:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, boldFormat);
break;
case Error:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, boldFormat);
break;
case Warning:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, boldFormat);
break;
default:
cursor.insertFrame(frameFormat);
cursor.insertText(txt, textFormat);
}
}
Code: Alles auswählen
qed.write( "Hello", QED::Edit );
qed.write( "World", QED::Edit );
qed.write( "Anybody", QED::Input );
qed.write( "Out", QED::Output );
qed.write( "There", QED::Error );
qed.write( "?", QED::Plain );
http://img159.imageshack.us/done.php?l= ... nntrd5.png
Grüße
Olaf
