开发者

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 the details. My problem is that the 'Title' field is way too big for me (~50% of the available screen estate). Here is a screen开发者_如何学JAVAshot, and there the *.ui-file.

I've already had a look at all the QWizard/QWizardPage properties and couldn't find anything that referred to the size/styling of the 'Title' field. Is there any way to do this (maybe using a custom stylesheet?) or am I out of luck?


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜