You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the ways I think this widget would be most useful, in terms of the greater Gtk4 ecosystem, is if it worked a simple-to-use, bare-bones display widget for rich-text rendered from various formats — say, as a starting point (and because it's the simplest of the markup formats), MarkDown.
Since Qt 5.14 their basic QTextEdit (as well as QTextBrowser and QTextDocument) has supported rendering of MarkDown source right in the widget, in addition to the (bare-bones Qt subset of) HTML source it already supported.
The interface is as easy as can be:
MarkdownDialog::MarkdownDialog(QWidget *parent)
: QDialog(parent)
{
std::string mdContent{R"md(# Markdown display demoQTextEdit can display editable or read-only rich text from MarkDown sourcewith simple API calls to render MarkDown *into* the widget, or to retrieveMarkDown *out* of the widget.It supports GitHub Flavored MarkDown by default (except that, for somereason, it parses underscores as _underline_ markup), including:|Feature |Notes ||------------------|-------------------||Tables | (as seen here) ||Ordered Lists | [See below](#OL) ||Unordered lists | [See below](#UL) ||Checklists | [See below](#CL) ||And much more | |## OL1. First item1. Second item 1. Nested## UL* Bullet 1* Bullet 2 * Nested## CL- [ ] Checkbox 1- [ ] Checkbox 2- [x] Checked box)md"};
auto* mdText = newQTextEdit(this);
this->layout()->addWidget(mdText);
mdText->setMarkdown(QString::fromStdString(mdContent));
mdText->setReadOnly(true);
mdText->setWordWrapMode(QTextOption::WordWrap);
mdText->show();
}
Write a barebones main.cpp that just creates the dialog and ->show()s it, compile and run, and...
Similarly, there's a QTextEdit::setHTML() for taking advantage of that barebones HTML subset I mentioned.
And that's in a standard QtWidgets component, built right into the framework — the equivalent of GtkTextView. It's insane that, even in 2024, Gtk4 doesn't provide rich-text functionality that's even close to that seamless.
Add a distinction between editable and non-editable text widgets
When used in display-only mode, see if we can disable or remove the editor logic to improve performance somewhat.
We'll need this for porting Extension Manager to 0.2.
The text was updated successfully, but these errors were encountered: