Код: Выделить всё
// Render checkbox
if (blockText == "- [ ]") {
cursor.beginEditBlock();
cursor.removeSelectedText();
QTextCharFormat fmt;
fmt.setObjectType(QTextFormat::UserObject + 1);
fmt.setProperty(1000, "checkbox");
fmt.setProperty(1001, true);
fmt.setFontPointSize(FONT_SIZE);
cursor.insertText(QString(QChar::ObjectReplacementCharacter), fmt);
cursor.endEditBlock();
return;
}
void MarkdownEditor::mousePressEvent(QMouseEvent *event)
{
QTextCursor cursor = cursorForPosition(event->pos());
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 1); // Select one character
QTextCharFormat fmt = cursor.charFormat();
if (fmt.objectType() == QTextFormat::UserObject + 1 &&
fmt.property(1000).toString() == "checkbox") {
//Toggle the checkbox state
bool checked = fmt.property(1001).toBool();
fmt.setProperty(1001, !checked);
cursor.setCharFormat(fmt); //
Любые указатели о том, как я могу понять основную графическую архитектуру приложений QT? Я сильно полагаюсь на LLMS для этого, но любые указатели понять, как это работает на более глубоком уровне, чтобы я мог устранения неполадок, было бы здорово.
Подробнее здесь: https://stackoverflow.com/questions/795 ... -qtextedit
Мобильная версия