View Full Version : Opensource rich text editor whose output QTextBrowser accepts
hvw59601
13th December 2007, 15:41
Hi,
I am using QTextBrowser to display a rich text file, .rtf, but I am having trouble finding an editor that will produce a file that QTextBrowser will accept.
E.g. I tried oowriter but QTextBrowser will not display that as RTF but just displays plain text (all the control statements).
I tried the startup file from http://www.nllgg.nl/Ted/ but it will not display that either.
I can put simple rtf code in a file and it does display that, but I want to use an editor and not have to code all the rtf stuff.
high_flyer
13th December 2007, 15:47
but I want to use an editor and not have to code all the rtf stuff.
From the docs:
If you want to provide your users with an editable rich text editor, use QTextEdit. If you want a text browser without hypertext navigation use QTextEdit, and use QTextEdit::setReadOnly() to disable editing. If you just need to display a small piece of rich text use QLabel.
And how exactly are you adding the text to the QTextBrowser?
hvw59601
13th December 2007, 15:58
Like in line 38:
void ApplicationWindow::Editor_2()
{
char name[32]="AppWin::Editor_2";
QString s,tt,tt1;
if( rtfAct->isChecked() ) {
QString tt = xlist->get_desc(xlist->get_varno("about_rtf_file"));
about_rtf_file.setName(tt);
if ( !about_rtf_file.exists() ) {
midget("%s does not exist %d %s\n",qPrintable(tt),__LINE__,__FILE__);
return;
}
if ( !about_rtf_file.open( QIODevice::ReadOnly ) ) {
midget("Could not open about_rtf_file: %s %d %s\n",qPrintable(tt),__LINE__,__FILE__);
return;
}
setCursor(Qt::waitCursor);
e_2 = new QTextBrowser( this, "editor" );
e_2->setGeometry(get_int("xxe"), get_int("yye"), get_int("wwe"), get_int("hhe"));
midget("debugger x=%d y=%d w=%d h=%d %d %s\n",get_int("xxe"), get_int("yye"), get_int("wwe"), get_int("hhe"),__LINE__,__FILE__);
// e->setDocumentTitle(debug_file);
e_2->setReadOnly(TRUE);
e_2->setAcceptRichText(TRUE);
e_2->setFocus();
e_2->clear();
int kk =0;
QTextStream t_t(&about_rtf_file);
while ( !t_t.atEnd() ) {
QString s = t_t.readLine();
qApp->processEvents();
e_2->append( s );
kk++;
}
midget("Read %d lines of about_rtf_file: %d %s\n",kk,__LINE__,__FILE__);
about_rtf_file.close();
setCursor(Qt::arrowCursor);
e_2->show();
}
else {
about_rtf_file.close();
delete e_2;
xdeb->hide();
ss->repaint();
}
emit(setStat());
high_flyer
13th December 2007, 16:10
try and see what does acceptRichText () return, you could also try and explicitly call setAcceptRichText ( true)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.