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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -