[SOLVED] how to get html bold to be inserted beside the selected word?
In the textedit, when the user selects the word and then clicks the bold button, i need the <b> and </b> to be inserted beside the word. in the text below, the bold works but not correctly the way i would want it because the <b> and </b> is not inserted beside the word and i don't need the word highlighted. can i have an example please?
if (ui->sayLineEdit->fontWeight() == QFont::Bold)
i searched the docs and found that selectedText() might work in this case but i am getting an error that textCursor() was not declared. how to declare it, and could i also get some help for my first question above please. thank you in advanced.
@QString TextEdit::textUnderCursor () const
QTextCursor tc = textCursor ();
return tc.selectedText ();
Add this at the top of your file:
i added the include but i still get an error 'textCursor' was not declared in this scope
i solved the textCursor issue. textCursor() should have been ui->textEdit->textCursor(). the selectedText() i can use to make the bold.
this topic is solved.