Results 1 to 9 of 9

Thread: emit a signal into an MdiSubWindow

  1. #1
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Exclamation emit a signal into an MdiSubWindow

    Hello , i'm using pyqt 4 and i have a issue with signals

    i'm trying to send a signal into an QmdiSubWindow , from my QMainWindow whenever a button is checked to tell the QMdiSubWindow that it has been checked ,
    so the way i proceed is like this :

    in my QMainWindow : i connect the signal to a fonction :
    Qt Code:
    1. self.connect (self.moveButton , SIGNAL("clicked()") , self.send_move_signal)
    To copy to clipboard, switch view to plain text mode 

    My send_move_Signal method :

    Qt Code:
    1. def send_move_signal(self):
    2. self.moveButton.setChecked(True)
    3. self.mdiArea.activeSubWindow().emit ( SIGNAL("moveButton_activated"))
    To copy to clipboard, switch view to plain text mode 

    and in the constructor of my Mdi-Widget i proceed like that :

    Qt Code:
    1. class MdiWid ( QWidget , Ui_SubMdiWindow):
    2. def __init__(self,parent=None):
    3. super(MdiWid,self).__init__(parent)
    4. self.connect (self , SIGNAL("moveButton_activated"),self.updateMoveState)
    5.  
    6. def updateMoveState(self):
    7. self.moveButton_activated = True
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work , and i don't see why

    Any help please ,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: emit a signal into an MdiSubWindow

    Why so complicated?

    Why not just call updateMoveState directly from send_move_signal?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default Re: emit a signal into an MdiSubWindow

    Thanks for your answer ,

    I just started learning to make Mdi Apps ,

    so, yes my solutions might be complicated

    how can i do it ??

    I tried this :
    Qt Code:
    1. def send_move_signal(self):
    2. currentMdi = self.mdiArea.activeSubWindow()
    3. currentMdi.updateMoveState()
    To copy to clipboard, switch view to plain text mode 

    But Got error : " QMdiSubWindow " has no attribute updateMoveState

    If i created an instance to the last opened MdiSubWindow it will work only on the last one but i want this signal to act on the current active Window

    Thanks,

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: emit a signal into an MdiSubWindow

    Ah, I would have assumed that Python's duck typing would recognize the method in your subclass.

    Then, how about this:
    - connect the button to all MdiWid instances
    - inside updateMoveState() you check if this is the active window. If yes you do something, if not you ignore the method call

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default Re: emit a signal into an MdiSubWindow

    Quote Originally Posted by anda_skoa View Post
    - connect the button to all MdiWid instances
    _
    i don't create an instance for each Opened MdiSubWindow , and i think we must not do it.

    The main problem here for me is to acess to the Currently Active Mdi Widget Methods ..

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: emit a signal into an MdiSubWindow

    Quote Originally Posted by Qtdigitex View Post
    i don't create an instance for each Opened MdiSubWindow , and i think we must not do it.
    That doesn't make any sense.

    You have an instance of your sub window class for every sub window.
    A window that doesn't exist isn't there at all.

    Quote Originally Posted by Qtdigitex View Post
    The main problem here for me is to acess to the Currently Active Mdi Widget Methods ..
    In C++ that would be a cast, look for whatever mechanism Python uses for such type conversions.

    Cheers,
    _

  7. #7
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default Re: emit a signal into an MdiSubWindow

    here's the function that load the document ( QWidget ) :

    Qt Code:
    1. def load(self):
    2. ImageProject = OIWid()
    3. self.mdiArea.addSubWindow(ImageProject)
    To copy to clipboard, switch view to plain text mode 

    i skipped details , but that's it. it's the code that load my widget.

    if i make ImageProject an instance variable of my main class ( QMainWindow ) : self.ImageProject instead of ImageProject,

    the last opened Project would be self.ImageProject and not the current active window !
    Last edited by Qtdigitex; 18th July 2016 at 22:22.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: emit a signal into an MdiSubWindow

    In you first post you had a class MdiWid, but I can't see that being used in your newest code snippet.

    Cheers,
    _

  9. #9
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default Re: emit a signal into an MdiSubWindow

    Hi , i finaly found the solution :

    i only needed to use the QMdiSubWindow's method : widget() to be able to acess my currently opened widget's methods and signals ...

    SO it will become :
    Qt Code:
    1. self.mdiArea.activeSubWindow().widget().update_move_state()
    To copy to clipboard, switch view to plain text mode 

    instead of :
    Qt Code:
    1. self.mdiArea.activeSubWindow().update_move_state()
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Seems that my emit doesn't emit the signal
    By roseicollis in forum Newbie
    Replies: 2
    Last Post: 19th January 2015, 16:05
  2. Widget paint artefacts on MdiSubwindow
    By oberlus in forum Qt Programming
    Replies: 1
    Last Post: 9th May 2012, 13:30
  3. QProgressBar appearance only in MdiSubWindow
    By revellix in forum Qt Programming
    Replies: 3
    Last Post: 17th August 2011, 13:54
  4. Could not get focus on input widgets in mdisubwindow
    By Askar in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2011, 14:29
  5. MDISubWindow will not resize
    By ad5xj in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2009, 22:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.