ostapische
ostapische

Reputation: 1592

QPushButton 100% height of QGridLayout's cell

qroupBoxButtons = new QGroupBox();  
QGridLayout *layout = new QGridLayout;  

pushButtonPlus = new QPushButton( tr( "+" ) );  
layout -> addWidget( pushButtonPlus, 1, 1 );  
/* add another elements to layout */  
layout -> setColumnStretch( 1, 25 );  
/* set column stretch to other columns */  
qroupBoxButtons -> setLayout( layout );  
/* add qroupBoxButtons to another QGroupBox's layout  

I'm trying to set 100% height like this:

pushButtonPlus -> setStyleSheet( " QPushButton { height: 100%; } " );  

or:

pushButtonPlus -> setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );

But it doesn't work normal. Button always have 100% of width and only standart height. And when window resizes it stay in one height.

How can I set 100% height without using resize event?

Upvotes: 2

Views: 2274

Answers (1)

LogicStuff
LogicStuff

Reputation: 19607

This is the way how to do that:

pushButtonPlus->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

I don't know why QSizePolicy::Ignored doesn't work for this, even if it's described in the documentation pretty straightforwardly.

Upvotes: 7

Related Questions