Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to install event listener for resizeEvents?
Forum Updated to NodeBB v4.3 + New Features

How to install event listener for resizeEvents?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 390 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SPlatten
    wrote on 3 May 2020, 12:20 last edited by
    #1

    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?

    Kind Regards,
    Sy

    J 1 Reply Last reply 3 May 2020, 12:54
    0
    • S SPlatten
      3 May 2020, 12:20

      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?

      J Online
      J Online
      JonB
      wrote on 3 May 2020, 12:54 last edited by
      #2

      @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()?

      1 Reply Last reply
      2
      • S Offline
        S Offline
        SPlatten
        wrote on 3 May 2020, 12:58 last edited by SPlatten 5 Mar 2020, 12:58
        #3

        @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.

        Kind Regards,
        Sy

        1 Reply Last reply
        0

        1/3

        3 May 2020, 12:20

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved