qt - QTextEdit check if its bold -
i have bold button when selected can set text , make bold follows:
qtextcursor cursor = this->ui->editnotes->textcursor(); qtextcharformat format; format.setfontweight(qfont::bold); cursor.mergecharformat(format);
the question how press same bold button , check if selected text bold? if bold remove bold same selection. have parse html code? example if @ text made bold html data is:
<span style=" font-family:'arial,helvetica'; font-size:14px; font-weight:600; color:#313131;">functions</span>
is there easier method parsing attributes text wrapped in check font-weight? or solution?
it old question, joined site month ago, couldn't answer earlier. solution use font()
, bold()
methods:
qtextcursor cursor = ui->textedit_2->textcursor(); qtextcharformat format; if(!cursor.charformat().font().bold()) { qdebug() << "not bold"; } else { qdebug() << "bold"; }
Comments
Post a Comment