QDataWidgetMapper, QTextEdit storing plain text
-
@mrjj I like the simple solutions best! Unfortunately not an option because I'm showing syntax highlighting of the contents. I want the syntax highlighter to do its job for display but have the DB store the plaintext.
This is a snippet manager. I want to use the snippets as plaintext in another context but allow the user to view and edit it with syntax highlighting.
-
@mrjj I like the simple solutions best! Unfortunately not an option because I'm showing syntax highlighting of the contents. I want the syntax highlighter to do its job for display but have the DB store the plaintext.
This is a snippet manager. I want to use the snippets as plaintext in another context but allow the user to view and edit it with syntax highlighting.
@cmulcahy
Me too but might been too easy :)
so its soemthing like
http://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.htmlIm wondering how you get the HTML back on next view?
You insert ( highlight) at runtime so its fine to throw the HTML away?Have you tried with
void QDataWidgetMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName)
and try to see if it will accept
plainText : QString
property ?
else you could subclass it and make such property.There is also
void QDataWidgetMapper::setItemDelegate(QAbstractItemDelegate *delegate)"Sets the item delegate to delegate. The delegate will be used to write data from the model into the widget and from the widget to the model"
Sounds like could be used.
-
void QDataWidgetMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName)
That was it. No matter how many times I stared at this definition on the documentation, it never occurred to me that propertyName should be wrapped in quotes.
mapper->addMapping(ui->scriptEditor, scriptmodel->fieldIndex("script"), "plainText");
-
void QDataWidgetMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName)
That was it. No matter how many times I stared at this definition on the documentation, it never occurred to me that propertyName should be wrapped in quotes.
mapper->addMapping(ui->scriptEditor, scriptmodel->fieldIndex("script"), "plainText");