2
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?

ostapische
  • 1,572
  • 2
  • 12
  • 26

1 Answers1

7

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.

LogicStuff
  • 19,397
  • 6
  • 54
  • 74
  • I'm trying to set up `QSizePolicy::Expanding` only for first argument in `setSizePolicy` and it was `width`. Thanks – ostapische Mar 16 '15 at 21:24