Results 1 to 4 of 4

Thread: Opensource rich text editor whose output QTextBrowser accepts

  1. #1
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default Opensource rich text editor whose output QTextBrowser accepts

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Opensource rich text editor whose output QTextBrowser accepts

    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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default Re: Opensource rich text editor whose output QTextBrowser accepts

    Like in line 38:

    Qt Code:
    1. void ApplicationWindow::Editor_2()
    2. {
    3. char name[32]="AppWin::Editor_2";
    4.  
    5. QString s,tt,tt1;
    6.  
    7. if( rtfAct->isChecked() ) {
    8. QString tt = xlist->get_desc(xlist->get_varno("about_rtf_file"));
    9.  
    10. about_rtf_file.setName(tt);
    11.  
    12. if ( !about_rtf_file.exists() ) {
    13. midget("%s does not exist %d %s\n",qPrintable(tt),__LINE__,__FILE__);
    14. return;
    15. }
    16.  
    17. if ( !about_rtf_file.open( QIODevice::ReadOnly ) ) {
    18. midget("Could not open about_rtf_file: %s %d %s\n",qPrintable(tt),__LINE__,__FILE__);
    19. return;
    20. }
    21.  
    22. setCursor(Qt::waitCursor);
    23.  
    24. e_2 = new QTextBrowser( this, "editor" );
    25. e_2->setGeometry(get_int("xxe"), get_int("yye"), get_int("wwe"), get_int("hhe"));
    26. 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__);
    27. // e->setDocumentTitle(debug_file);
    28. e_2->setReadOnly(TRUE);
    29. e_2->setAcceptRichText(TRUE);
    30. e_2->setFocus();
    31. e_2->clear();
    32.  
    33. int kk =0;
    34. QTextStream t_t(&about_rtf_file);
    35. while ( !t_t.atEnd() ) {
    36. QString s = t_t.readLine();
    37. qApp->processEvents();
    38. e_2->append( s );
    39. kk++;
    40. }
    41. midget("Read %d lines of about_rtf_file: %d %s\n",kk,__LINE__,__FILE__);
    42. about_rtf_file.close();
    43. setCursor(Qt::arrowCursor);
    44. e_2->show();
    45. }
    46. else {
    47. about_rtf_file.close();
    48. delete e_2;
    49. xdeb->hide();
    50. ss->repaint();
    51. }
    52.  
    53. emit(setStat());
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Opensource rich text editor whose output QTextBrowser accepts

    try and see what does acceptRichText () return, you could also try and explicitly call setAcceptRichText ( true)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.