Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] QMdiSubWindow and Widget Checks

    General and Desktop
    2
    3
    999
    Loading More Posts
    • 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.
    • R
      rizoritis last edited by

      Hello,

      I am using the following functions to add a subwindow to my mdiarea and to set a widget to the subwindow:

      @ mdisubwindow->setWidget(widget); /Add the widget to the subwindow/
      mdiarea->addSubWindow(mdisubwindow); /Add subwindow to the mdiarea/@

      I would like to put if statements prior to each call to

      1. first check if a widget has already been set to that particular subwindow
        2)check if the subwindow has already been added to the mdiarea

      So it should look like this:

      @ if(!widget is already set to mdisubwindow)
      {
      mdisubwindow->setWidget(widget);
      }
      if(!subwindow is already added to mdiarea)
      {
      mdiarea->addSubWindow(mdisubwindow);
      } @

      Any ideas would help because I cannot seem to find this anywhere...

      Thanks

      1 Reply Last reply Reply Quote 0
      • jazzycamel
        jazzycamel last edited by

        1. mdisubwindow->widget() will give you a reference to the current widget if any.
        2. mdiarea->subWindowList() will give you a list of all the subwindows currently in the QMdiArea so you can check if mdisubwindow is among them.

        For the avoidance of doubt:

        1. All my code samples (C++ or Python) are tested before posting
        2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
        1 Reply Last reply Reply Quote 0
        • R
          rizoritis last edited by

          [quote author="jazzycamel" date="1372435109"]1) mdisubwindow->widget() will give you a reference to the current widget if any.
          2) mdiarea->subWindowList() will give you a list of all the subwindows currently in the QMdiArea so you can check if mdisubwindow is among them.[/quote]

          Thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post