While QLabel
uses a QTextDocument
internally when rendering rich text, it does not allow access to it in it's API. However, since QTextDocument
is a QObject
, you can try to use
QTextDocument * tl = label->findChild<QTextDocument>();
to get access to it (will work if the QLabel
creates the QTextDocument
as a (direct or indirect) child of itself).
Once you have a pointer to the text document, you can use the QTextDocument
API, e.g. QTextOption::setTabsStop()
, to change the tab stops.
The last step is to somehow make the QLabel
repaint itself. Probably a call to QWidget::update()
suffices, but caching (or worse, recreating the text document) might thward that. In this case, you can register an event listener on the label to adjust the text document just prior to a paintEvent()
, but note that the sizeHint()
might also change when the tab stops change, so it might be more complicated still.
That said, it's how I'd approach the problem.