Srv19 Srv19 - 3 months ago 61
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?


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);