Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt rich text editor - is there an already-made one? [closed]

I need a rich text editor for Qt. I've been thinking about using QTextEdit since it's a rich text edit, but I need two things that aren't present in that widget:

  • The user should be able to change the text color, the text font, underline, bold, italic the text, so I need something like a text editor toolbar with these controls (do I need to code them by myself?)

  • The user should be able to drag'n'drop or add by searching for it an image. Now if I try to copy-and-paste an image onto my QTextEdit I just see this

enter image description here

How should I do for each one of my needs?

like image 997
Johnny Pauling Avatar asked Jul 24 '12 12:07

Johnny Pauling


People also ask

Which rich text editor is best?

Over 1.5M developers agree TinyMCE is the rich text editor of choice. With an open-source core and additional premium add-ons, TinyMCE scales with your app as you grow. Use TinyMCE as: A basic editor.

How do I activate rich text editor?

Right-click the rich text box for which you want to enable or disable full rich-text formatting, and then click Rich Text Box Properties on the shortcut menu. Click the Display tab. To enable full rich-text formatting for the selected rich text box, select the Full rich text (images, tables, etc.)

Is rich text editor Free?

There is no charge. Put Rich Text Editor to the test in your own specific applications.

How does Richtext editor work?

The Rich Text Editor is a tool that allows you to add or edit content, images, links, and other components on the page without having to know any code. It displays the content and any formatting as it would display in the browser.


2 Answers

1) Have a look at this official example, it should give you a rich text editor that is able to change the text, with a toolbar:

http://doc.qt.io/qt-5/qtwidgets-richtext-textedit-textedit-cpp.html

To drag and drop images, I'm afraid you will have to subclass a text edit (either QTextEdit or QTextBrowser) and implement these two methods:

void QTextEdit::dropImage(QImage const& p_image, QString const& p_format)
void QTextEdit::insertFromMimeData(const QMimeData* p_source)

2) Here is a GitHub project that implements all you need and even more:

https://github.com/Anchakor/MRichTextEditor


Lastly, if you want to understand how rich text editors work, here is the documentation:

http://doc.qt.io/qt-5/richtext.html

like image 87
Emma Michelet Avatar answered Nov 15 '22 00:11

Emma Michelet


You can use this editor extracted from Deko the CRM: http://www.hobrasoft.cz/en/blog/bravenec/qt-rich-text-editor

like image 31
Petr Bravenec Avatar answered Nov 14 '22 23:11

Petr Bravenec