QWizard padding around QWizardPage
-
I have made a full screen wizard in my application that derives from QWizard and QWizardPage. What I have found is that I always end up with some blank space around the QWizardPage, with the edges of the QWizardPage cut off. I would like to have my QWizardPage display across the entire screen without the margins.
I have tried setting both the wizard and page to have fixed sizes (the same size), creating a layout on the QWizard then setting the content margins to all zeros. Setting the style sheet to use all zeros for all box model options and overriding the paint event on both to try and fix the issue. In the paint event of the QWizardPage it appeared that it only had access to the "shrunk" size.
Has anyone else seen this behaviour and do you know how I could fix it?
There is about 10 pixels cut off on each edge. The left edge of my screen looks like the scaled down image below, when the grey at the bottom should extend to the leftmost edge and to the bottom.
Thanks in advance.
-
Hi and welcome to devnet,
Please post the version of Qt you are using as well as OS and compiler.
A minimal compilable example to reproduce this would be great.
-
Thanks SGaist and sorry for the lack of information,
I am using Qt 5.9.1 with gcc (SUSE Linux) 4.8.5, on operating system openSUSE Leap 42.1
I have copied an example below (I don't have permissions to upload yet sorry). This example has just a QWizard and QWizardPage that has two square buttons at the very edges of the QWizardPage. When I run it on my system the two button's edges are cut off and the black background shows around the cut off buttons.
I have not attempted to set margins, set style sheet or override paint events to keep it simple.
///main.cpp #include "wizard.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Wizard wizardExample; wizardExample.show(); return a.exec(); } ///wizard.h #include <QWizard> namespace Ui { class Wizard; } class Wizard : public QWizard { Q_OBJECT public: explicit Wizard(QWidget *parent = 0); ~Wizard(); private: Ui::Wizard *ui; }; ///wizard.cpp #include "wizard.h" #include "ui_wizard.h" Wizard::Wizard(QWidget *parent) : QWizard(parent), ui(new Ui::Wizard) { ui->setupUi(this); //remove all the standard buttons from the layout QList<QWizard::WizardButton> btnLayout; setButtonLayout(btnLayout); } Wizard::~Wizard() { delete ui; } ///wizardpage.h #include <QWizardPage> namespace Ui { class WizardPage; } class WizardPage : public QWizardPage { Q_OBJECT public: explicit WizardPage(QWidget *parent = 0); ~WizardPage(); private: Ui::WizardPage *ui; }; ///wizardpage.cpp #include "wizardpage.h" #include "ui_wizardpage.h" WizardPage::WizardPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::WizardPage) { ui->setupUi(this); } WizardPage::~WizardPage() { delete ui; } //wizard.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Wizard</class> <widget class="QWizard" name="Wizard"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>400</height> </rect> </property> <property name="palette"> <palette> <active> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>255</red> <green>255</green> <blue>255</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>0</blue> </color> </brush> </colorrole> </active> <inactive> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>255</red> <green>255</green> <blue>255</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>0</blue> </color> </brush> </colorrole> </inactive> <disabled> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>0</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>0</blue> </color> </brush> </colorrole> </disabled> </palette> </property> <property name="windowTitle"> <string>Dialog</string> </property> <property name="wizardStyle"> <enum>QWizard::NStyles</enum> </property> <property name="options"> <set>QWizard::NoBackButtonOnLastPage|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButton|QWizard::NoCancelButtonOnLastPage|QWizard::NoDefaultButton</set> </property> <widget class="WizardPage" name="wizardPage"/> </widget> <customwidgets> <customwidget> <class>WizardPage</class> <extends>QWizardPage</extends> <header>wizardpage.h</header> <container>1</container> </customwidget> </customwidgets> <resources/> <connections/> </ui> ///wizardpage.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>WizardPage</class> <widget class="QWizardPage" name="WizardPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>400</height> </rect> </property> <property name="palette"> <palette> <active> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>255</red> <green>255</green> <blue>255</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>255</blue> </color> </brush> </colorrole> </active> <inactive> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>255</red> <green>255</green> <blue>255</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>255</blue> </color> </brush> </colorrole> </inactive> <disabled> <colorrole role="Base"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>255</blue> </color> </brush> </colorrole> <colorrole role="Window"> <brush brushstyle="SolidPattern"> <color alpha="255"> <red>0</red> <green>0</green> <blue>255</blue> </color> </brush> </colorrole> </disabled> </palette> </property> <property name="windowTitle"> <string>Dialog</string> </property> <widget class="QPushButton" name="btnBottomLeft"> <property name="geometry"> <rect> <x>0</x> <y>280</y> <width>120</width> <height>120</height> </rect> </property> <property name="text"> <string>Do Something</string> </property> </widget> <widget class="QPushButton" name="btnTopRight"> <property name="geometry"> <rect> <x>280</x> <y>0</y> <width>120</width> <height>120</height> </rect> </property> <property name="text"> <string>Do Something</string> </property> </widget> </widget> <resources/> <connections/> </ui>
-
From a quick look at the code of QWizard/QWizardPage, it seems that this widget is rather tightly related to the style to in order to match the platform specific wizard look and feel.
So all in all, you should maybe consider create your own wizard for your use case.