开发者

Qt - QPushButton newline not working

I tried \n and \r\n, but I can't get two lines of text to display correctly. I'm coding a mobile Qt app.

QPushButton *button = new QPu开发者_StackOverflow社区shButton(QString("long lines of \n text"));
button->setMaximumWidth(320);


I'm not sure if you assign the parent for the button later but when I try that code from within in a QWidget based form and pass a parent in, I get a button with two lines of text on it.

QPushButton *button = new QPushButton(QString("long lines of \n text", this));
button->setMaximumWidth(320);

Setting the maximum width won't prevent the button from being sized smaller by a layout. The \n should be causing the text to span two lines so something related to a layout is probably restricting the size of the button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜