In C++, how to set line height with qt component?

159 Views Asked by At

In C++,I am trying to set line height.

if (auto message = guideMsgWidget->getMessageTextEdit())
{
    message->setTextStyle("font-size: 12px; text-align: left; color: #1b1b1e;");
}

Here's the thing. getMessageTextEdit() function returns component which inherit QWidget. So I'm tring to put line height in setstylesheet. But it doesn't work.

I've tried using QTextBlockFormat and Cursor.

here's one of code that i've tried.

if (auto message = guideMsgWidget->getMessageTextEdit())
{
    QString existingStyle = message->styleSheet();
    QString newStyle = QString("QTextEdit {%1 line-height: 1.5;}").arg(existingStyle);
    message->setStyleSheet(newStyle);
}
0

There are 0 best solutions below