html - QTextBlockFormat.setLeftMargin(1em): How To? -
in html-list bullets, on change of fontsize via format.setfontpointsize() bullets drive out of editor. figured out bullets stay on same position on fontsize-change if set padding-left 1em (tried in html-editor). how can achieve list entry in qt? can set pixel value , not element value?
fmt=cur.charformat() charsize=fmt.fontpointsize() if charsize==0.0: charsize=14 if direction=="up": fmt.setfontpointsize(charsize+1) if textlist: blockformat=cur.blockformat() #blockformat.setleftmargin(blockformat.leftmargin()+0.4) blockformat.setleftmargin(1em) cur.mergeblockformat(blockformat) else: fmt.setfontpointsize(charsize-1) if textlist: blockformat=cur.blockformat() #blockformat.setleftmargin(blockformat.leftmargin()-0.4) blockformat.setleftmargin(1em) cur.mergeblockformat(blockformat) cur.mergecharformat(fmt)
you can set default indentation text lists in qtextdocument instance creating (i think default 40). multiples of value used each indentation level in list.
qtextdocument *doc = new qtextdocument(); doc->setindentwidth(20); qtextcursor *cursor = new qtextcursor(doc); qtextlistformat listformat; listformat.setindent(1); // first indent level, indent 20 cursor->insertlist(listformat); // insert items list listformat.setindent(2); // second indent level, indent 40 cursor->insertlist(listformat); // insert nested list items
Comments
Post a Comment