Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to install event listener for resizeEvents?



  • In my code I create a new QWidget:

        QWidget* pobjWin = new QWidget();
    

    I get a pointer to a window:

        QWindow* pobjWindow = pobjWin = pobjWn->windowHandle();
    

    So far so good, I can then set the window title and resizable properties for this window:

        Qt::WindowFlags wndFlags = 0;
        //In the case of a window not being resizable
        wndFlags |= Qt::Dialog | Qt::MSWindowsFixedSizeDialogHight;
        //Set the window as frameless
        wndFlags |= Qt::Window | Qt::FramelessWindowHint;
        if ( wndFlags != 0 ) {
            pobjWnd->setWindowFlags(wndFlags);
        }
        //Show the window
        pobjWin->show();
        //Store the window with the node
        setWidget(pobjWin);
    

    Of course this isn't all the code , just a very small part of it. What I would like to do is add a listener to handle when the window is resizable.

    The question is how do I add an event listener to handle the resizeEvent?



  • @SPlatten
    Not sure why you're at the "window handle" level of things? If you subclass you can use QWidget::resizeEvent(), else/if not QObject::installEventFilter()?



  • @SPlatten
    Not sure why you're at the "window handle" level of things? If you subclass you can use QWidget::resizeEvent(), else/if not QObject::installEventFilter()?



  • @JonB, Thank you, the reason why I'm doing it this way is my application is an engine where any number of windows can be created dynamically and any type of widgets can also be created.

    I'm trying to do things in as flexibly and dynamically as possible. I've seen snippets online of QObject::installEventFilter(). I guess I'm being a bit lazy by hoping someone would past in an example of it including the resizeEvent.


Log in to reply