I need a text editor for Qt. I was thinking about using QTextEdit as it is text editing, but I need two things that are not in this widget:
The user should be able to change the text color, text font, underline, bold, italic text, so I need something like a text editor toolbar with these controls (do I need to encode them myself?)
The user must be able to drag and drop while searching for this image. Now, if I try to copy and paste the image into my QTextEdit, I just see this
How do I do for each of my needs?
1) Look at this official example, it should provide you with a rich text editor that can change the text using the 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 text editing (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 everything you need, and even more:
https://github.com/Anchakor/MRichTextEditor
Finally, if you want to understand how text editors work, here is the documentation:
http://doc.qt.io/qt-5/richtext.html
You can use this editor extracted from Deko CRM: http://www.hobrasoft.cz/en/blog/bravenec/qt-rich-text-editor
Another idea would be to use WebKit to create this widget. See: http://blog.qt.digia.com/blog/2009/03/12/wysiwyg-html-editor/
Note that the associated git repository has moved to this URL: https://qt.gitorious.org/qt-labs/graphics-dojo/source/8000ca3b229344ed2ba2ae81ed5ebaee86e9d63a :
wwWidgets has RichTextEditor β http://www.wysota.eu.org/wwwidgets/doc/html/qwwrichtextedit.html
Source: https://habr.com/ru/post/921201/More articles:HttpWebRequest + Windows Auth - NetworkCredential just doesn't work - securityDeclaring awk in bash - linuxHow to get a list of all open files in eclipse editor? - javaAmbiguous method call between extension methods - c #Show all model validation errors at the top of the page in cakePHP - phpSQL error - incorrect table definition; there can be only one automatic column - sqlUnexpected PHP behavior unpack () - phpPHP Pack / unpack - can handle variable length strings - phpGoogle Map jQuery - getting LatLng with the mouse - javascriptReading a simple Avro file from HDFS - javaAll Articles