4.4.2014

foto Petr Bravenec

Petr Bravenec
Twitter: @BravenecPetr
+420 777 566 384
petr.bravenec@hobrasoft.cz

Qt toolkit has built-in html editor - class QTextEdit. The problem is that the editor has no controls which allows you to format the text. For the reason our colleague Jiří Procházka created simple editor, class MRichTextEdit, which we can use in our application Deko the CRM.

Editor is freely available (except icons, Jiří relies on the environment support), you can download it here:
https://github.com/Anchakor/MRichTextEditor

Basic features

  • Accepts html or plain text
  • Undo, Redo
  • Cut, copy a paste
  • Html links
  • Standard html formats (h1, h2...)
  • Text formats: bold, italics, underline, stroke, font size
  • Unnumbered or numbered lists
  • Text background color
  • Images embedded in html document

Another free software for Qt

Usage

Usage is very simple, all screen shots were created using a few lines in a C++ application:

    QDialog *dialog = new QDialog(this);
    MRichTextEdit *rte = new MRichTextEdit(dialog);
    QGridLayout *gl = new QGridLayout(dialog);
    gl-<addWidget(rte,0,0,1,1);
    dialog-<setWindowTitle(tr("Rich text editor"));
    dialog-<setMinimumWidth (400);
    dialog-<setMinimumHeight(400);
    dialog-<show();

Editor accepts plain text or html:

  • void setText(const QString& text) - recognizes simple text or html

Returns test in different formats:

  • QString toPlainText()
  • - returns plain text without html formatting
  • QString toHtml()
  • - returns complete html document
  • QTextDocument *document()
  • - return Qt class QTextDocument

Screen shots

Hobrasoft s.r.o. | Contact