From kde-bindings Fri Feb 19 19:29:11 2010 From: IBBoard Date: Fri, 19 Feb 2010 19:29:11 +0000 To: kde-bindings Subject: Re: [Kde-bindings] Qt, Qyoto buttons work intermediately Message-Id: <4B7EE687.50403 () gmail ! com> X-MARC-Message: https://marc.info/?l=kde-bindings&m=126660780116523 On 18/02/10 21:22, Linuxoid Oz wrote: > Thank you. I more or less understand how signals/slots operate from the > main window. I just don't get how they work if I have to open a second > window from the main window and display a message by clicking a button > in the second window with passing some variables to it. That's the problem. So you want to have a signal from MainWindow open ChildWindow, but ChildWindow needs to be created with some variables? That gives you one of two options (examples in pseudo-code - they may be almost valid, or they may be more WinForms/GTK#/SWT-like!): 1) Construct the window first and just open it on the action: private ChildWindow child; private UI_MainWindow layout; public MainWindow() { child = new ChildWindow(this, extraParam1); //Use delegate connect for refactorability and .Net-ish-ness QObject.Connect(layout.button, SIGNAL("triggered()"), ShowChildWindow); } private void ShowChildWindow() { //Could also set extra params here child.Show(); } The problem there is that you're constructing it before it is needed, which might not always be good, especially if it is resource intensive and rarely used. 2) Construct the window when you need it and pass the values in then: private UI_MainWindow layout; public MainWindow() { //Use delegate connect for refactorability and .Net-ish-ness QObject.Connect(layout.button, SIGNAL("triggered()"), ShowChildWindow); } private void ShowChildWindow() { ChildWindow child = new ChildWindow(); child.Title = GetTitleFromSomeMainWindowControl(); child.Show(); } This is probably better in most cases. The only constraint is that you need to be able to get the variables you need at the point where the method is called, rather than when you first connect the slot to the signal or create the child window. Hopefully that helps and covers the situation you've got. _______________________________________________ Kde-bindings mailing list Kde-bindings@kde.org https://mail.kde.org/mailman/listinfo/kde-bindings