Skip to content Skip to sidebar Skip to footer

Qwizard: Change Height/dimensions Of Title Field

I'm currently trying to implement a simple 'First steps' Wizard for a Python/Qt application I'm working on. This is really easy to do with Designer, but as usual the devil lies in

Solution 1:

The title label is in an internal QGridLayout, and unless you either add a layout to the page (or explicitly set the vertical size policy of the page to MinimumExpanding or Expanding) to force the grid cell containing the page to expand, the title will always take 50% of the total height.

Solution 2:

If the pixmap is set, like with the QWizard::WatermarkPixmap on the QWizard::ModernStyle, the height will be locked no matter what.

To get around this, use setSideWidget().

In the constructor for your subclass of QWizard

this->setWizardStyle(QWizard::ModernStyle);

//    setPixmap(QWizard::WatermarkPixmap, QPixmap(":/watermark.gif"));
QWidget * sideWidget = new QWidget();
QGridLayout * gridLayout = new QGridLayout();
QLabel * label = new QLabel();
label->setPixmap(QPixmap(":/watermark.gif"));
sideWidget->setLayout(gridLayout);
gridLayout->addWidget(label);
this->setSideWidget(sideWidget);


//this->setSizePolicy(QSizePolicy::MinimumExpanding ,QSizePolicy::MinimumExpanding );

And lastly to make the title box adjust upon a fontsize change, the easiest hack is to adjust the height of a pixmap and set it in the QWizard::LogoPixmap.

int numOfLinesInTitleBox = 2;
QPixmap p(1,this->fontMetrics().height()*numOfLinesInTitleBox);
p.fill(Qt::transparent);
setPixmap(QWizard::LogoPixmap, p);
this->adjustSize();

Hope that helps.

Post a Comment for "Qwizard: Change Height/dimensions Of Title Field"