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 use QMdiSubWindow classes ?
Forum Updated to NodeBB v4.3 + New Features

How to use QMdiSubWindow classes ?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 2.8k 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.
  • QtDigitexQ Offline
    QtDigitexQ Offline
    QtDigitex
    wrote on last edited by QtDigitex
    #1

    Hi ,

    i'm using pyqt4 and trying to make an MDI little application :

    i have two script : the main one inherits from QMainWindow and the second one that inherits from QWidget : it represents the type of document my application open each time i click on Open.

    i'm having trouble about two issues :

    • How to send a signal from my main script to the CURRENTLY ACTIVE Widget ( even if i opened several documents ) in order to run a method that's inside the widget class ( opened document ) ?

    • Isn't it possible to run the methods inside my Widget class whithout sending a signal ?
      I tried this :

    self.actualWidget = self.mdiArea.activeSubWindow()
    self.actualWidget.test_method()   # test_method is just for testing if it will run 
    

    i always get the error message :

    AttributeError : 'QMdiSubWindow' has no attribute 'test_method'.
    

    it's just as if activeSubWindow() returns a QMdiSubWindow instead of my CURRENTLY ACTIVE Widget ...

    Any Help please ? !

    Thanks,

    jsulmJ 1 Reply Last reply
    0
    • QtDigitexQ QtDigitex

      Hi ,

      i'm using pyqt4 and trying to make an MDI little application :

      i have two script : the main one inherits from QMainWindow and the second one that inherits from QWidget : it represents the type of document my application open each time i click on Open.

      i'm having trouble about two issues :

      • How to send a signal from my main script to the CURRENTLY ACTIVE Widget ( even if i opened several documents ) in order to run a method that's inside the widget class ( opened document ) ?

      • Isn't it possible to run the methods inside my Widget class whithout sending a signal ?
        I tried this :

      self.actualWidget = self.mdiArea.activeSubWindow()
      self.actualWidget.test_method()   # test_method is just for testing if it will run 
      

      i always get the error message :

      AttributeError : 'QMdiSubWindow' has no attribute 'test_method'.
      

      it's just as if activeSubWindow() returns a QMdiSubWindow instead of my CURRENTLY ACTIVE Widget ...

      Any Help please ? !

      Thanks,

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @QtDigitex For me it is not clear how you use your QWidget derived class as MDI sub window? If you put your QWidget class in a QMdiSubWindow then you have to get it from there first and then call your methods.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • QtDigitexQ Offline
        QtDigitexQ Offline
        QtDigitex
        wrote on last edited by QtDigitex
        #3

        Hi ,

        yes , i don't know how to do it , it's my first time . this is what i did :

        i made the design of both ( Main window & documents window ( it's a QGraphicsView +
        QTableWidget for each opened file ) )Via QtDesigner , so i choosed to create a QWidget ( there's no QMdiSubWindow ) and got the py code via pyuic4.

        in my secondary class i wrote :

        class Window_Widget (  QWidget , Ui_Form) : # Since i choosed in QtDesigner to create a QWidget and it's name is Form ( the Ui_Form class is issued from pyuic 4 )
        

        i think the problem comes from here , because if i change QWidget to QMdiSubWindow , the signals works greatly but the design and layouts that i made in QtDesigner breaks down ...

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @QtDigitex said:

          QMdiSubWindow

          Hi Normally , you talk to the widget you have inside the mdi window.
          If using a plain MDIwindow, then you insert your widget with
          http://doc.qt.io/qt-4.8/qmdisubwindow.html#setWidget
          and get with widget()
          And then cast to the correct type to call functions.

          Alternative you derive from QMdiSubWindow and expand with new functions.

          1 Reply Last reply
          0
          • QtDigitexQ Offline
            QtDigitexQ Offline
            QtDigitex
            wrote on last edited by QtDigitex
            #5

            Thank you so much ,

            all the problem comes from not accessing the widget Inside my QmdiSUbWindow , the widget() method resolved the problem. Now it works perfectly , thanks.

            But , can you please detail your second method , you mean that my secondary class must inherits QMdiSubWindow like this ? :

            class Widget_Window ( QMdiSubWindow , Ui_Form):
            

            the problem is that i made the design with QtDesigner and the code like this breaks all the layouts and the display. However , signals work

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              uhh, Im python noob :)
              so not sure about syntax.

              in c++, it would be
              class MyMDI : QMdiSubWindow
              Then the actual MDIsubWindow would be your type and could have extra functions.
              You would then have to new MYMDI and give to the Area with
              http://doc.qt.io/qt-5/qmdiarea.html#addSubWindow

              and when using activeSubWindow, you would cast to myMDI type and call functions.
              ( talking c++, python ,might allow something else :)

              1 Reply Last reply
              0
              • QtDigitexQ Offline
                QtDigitexQ Offline
                QtDigitex
                wrote on last edited by
                #7

                Ok Thanks

                1 Reply Last reply
                1

                • Login

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