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.
精彩评论