Results 1 to 13 of 13

Thread: connect

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default connect

    Hi, I've this problem; I need to connect a signal to a SLOT of myMainForm...How to do this? What's the best way to do this? thanks
    Qt Code:
    1. void myDialog::init() {
    2. myMainForm* myw; //how obtain this
    3. connect(buttonGroupLL, SIGNAL(clicked(int)), myw, SLOT(activeTab(int)));
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: connect

    Keep a pointer to this widget as a member of the dialog class and initialise it in the constructor of a dialog. Alternatively, if the widget is a parent of the dialog, you can use parent() call to retrieve it.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    sorry, the problem is that function init() is inside a dialog.ui.h (create from designer).....
    it hasn't parent...(I think)
    Regards

  4. #4
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    furthermore, I need that mydialog.ui.h can see the state button of myainForm and viceversa....
    Regards

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: connect

    You won't be able to do it with .ui.h. You have to subclass and reimplement the constructor. Remember that using "ui.h" is deprecated and that it is only a hack to avoid the need to subclass in common situations.

  6. #6
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    sorry,
    1. why is it deprecated?
    2.is it right create a dialog.ui.h from designer (leave that file empty) and sublcass it (and write code only here). Or which is the right way? thanks a lot
    Regards

  7. #7
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: connect

    You dont must create any *.ui.h files ! Actually Wysota explaine you upper why
    Now do this things :]
    - create form in Designer, set his name as FormBase and save it ;
    - add this form to your project and create class Form that will be inherit your FormBase;
    - use all members of FormBase in your Form class;

    Have you understand
    a life without programming is like an empty bottle

  8. #8
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    no I haven't understand. In designer if I create a form(dialog?), when I save it, its extension is .ui! How don't create .ui???
    Regards

  9. #9
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: connect

    You dont must create ui.h
    a life without programming is like an empty bottle

  10. #10
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    if I save dialog from designer automatically a .ui.h is created.....
    Regards

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: connect

    No. ui.h files are created when you enter some code into the form. And you're first asked if you want one to be created for you.

    Anyway, that's all not the point. You can use .ui.h files if you insist to, but you need to subclass the class created by designer+uic anyway.

  12. #12
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: connect

    Quote Originally Posted by wysota
    Keep a pointer to this widget as a member of the dialog class and initialise it in the constructor of a dialog.
    yes, I made this.
    Qt Code:
    1. myMainForm* _myw;
    2.  
    3. myLightDialog::myLightDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
    4. :lightDialog (parent, name, modal, fl), _myw ( ????)( {
    5. }
    To copy to clipboard, switch view to plain text mode 
    Actually mymainForm isn't parent of myLightDialog...
    Regards

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: connect

    So pass a pointer to it in the constructor.

    You are posting in Qt programming section of the forum, I assume you know C++ basics, don't you? This issue doesn't have anything to do with Qt. It's a simple C++ issue of storing a pointer to an object as a class member.

Similar Threads

  1. connect on a popup
    By mickey in forum Qt Programming
    Replies: 2
    Last Post: 12th April 2006, 16:37
  2. [QT4 & XP] connect on QtreeView
    By incapacitant in forum Newbie
    Replies: 1
    Last Post: 2nd March 2006, 11:08
  3. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06
  4. connect
    By mickey in forum Newbie
    Replies: 1
    Last Post: 25th February 2006, 18:31

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.