Srv19 Srv19 -4 years ago 245
C++ Question

Enable maximize button in QWizard

I have a Windows application that is built on QWizard (which inherits from QDialog). It must have a working maximization button.

By default maximization button is not even visible. i have set it to show, using:

auto flags = windowFlags();
flags ^= Qt::WindowContextHelpButtonHint;
flags |= Qt::WindowMinMaxButtonsHint;

However, it shows up disabled (grayed out, non-responding).

How can i enable it?

Answer Source

I believe that you'll get better results creating your own dialog, but if you really wanna do it, one way is use window styles (Windows only, not cross-plataform).

Wizard class example:

class wizard : public QWizard
    wizard() {}
    ~wizard() {}

    bool event(QEvent *event)
#ifdef Q_OS_WIN /*Make this code Windows OS only*/
        if (event->type() == QEvent::WinIdChange)
            HWND hwnd = (HWND)winId();
            LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
            lStyle |= (WS_MINIMIZEBOX | WS_MAXIMIZEBOX); /*Enable minimize and maximize*/
            SetWindowLong(hwnd, GWL_STYLE, lStyle);

        return QWizard::event(event);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download