Results 1 to 16 of 16

Thread: connect

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

    Default connect

    hi, why do I have this console error?? thanks
    Qt Code:
    1. //my is a pointer to MainForm class
    2. //I'm inside MyWidget constructor
    3. connect (my->pushButton21, SIGNAL (pressed()), this, SLOT (mySlot()) );
    4. QObject::connect: Cannot connect (null)::pressed() to MyWidget::mySlot()
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Maybe because my->pushButton21 is null?

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

    Default Re: connect

    ok. but why is it null? button21 is a button of mainform; how do I use it?
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Quote Originally Posted by mickey
    ok. but why is it null? button21 is a button of mainform; how do I use it?
    How do you create that "my" object? Maybe you create MyWidget before you initialize button21?

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

    Default Re: connect

    hi, I don't understand qaht you want say.....the situation is this..
    Qt Code:
    1. MyWidget::MyWidget( QWidget *parent, const char *name, const QGLWidget* shareWidget)
    2. : QGLWidget ( parent, name, shareWidget){
    3. my = (myMainForm*) this->topLevelWidget();
    4. connect (w->pushButton21, SIGNAL (pressed()), this, SLOT (myStartTimer()) );
    5. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Could you post myMainForm constructor?

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

    Default Re: connect

    do u want this?
    Qt Code:
    1. myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
    2. : MainForm( parent, name, fl )
    3. {
    4. ..............
    5. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Quote Originally Posted by mickey
    do u want this?
    Yes, do you initialize pushButton21 there?

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

    Default Re: connect

    Quote Originally Posted by jacek
    Yes, do you initialize pushButton21 there?
    what do you mean? I insert butt21 from designer....
    Regards

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Quote Originally Posted by mickey
    I insert butt21 from designer....
    In that case maybe this is wrong:
    Qt Code:
    1. my = (myMainForm*) this->topLevelWidget();
    To copy to clipboard, switch view to plain text mode 
    What happens when you use dynamic_cast?
    Qt Code:
    1. my = dynamic_cast< myMainForm*>( topLevelWidget() );
    2. Q_CHECK_PTR( my );
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: connect

    a rutime error!!! and application is closed...
    and without casting (my way) Q_CHECK_PTR( my ); doens't get any arror...
    but my is:
    Qt Code:
    1. myMainForm* my;
    To copy to clipboard, switch view to plain text mode 
    Regards

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    Quote Originally Posted by mickey
    a rutime error!!! and application is closed...
    This means that topLevelWidget() might return some other widget than myMainForm.

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

    Default Re: connect

    hi, using that bellow
    Qt Code:
    1. myw = (myMainForm*) this->topLevelWidget();
    To copy to clipboard, switch view to plain text mode 
    it print the follow pointer
    Qt Code:
    1. my_mainfom in myWidget 0012E388
    2. mainfom this in MainForm 0012E388
    3. my_mainfom this in myMainForm 0012E388
    To copy to clipboard, switch view to plain text mode 
    so myw in MyWidget point to mainForm.....have you any idea? thanks
    Regards

  14. #14
    Join Date
    Apr 2006
    Location
    Erlangen, Germany
    Posts
    58
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    if you created the window in the designer you have to call setupUi( this ); first thing in your classes constructor. Afterwards your pushbutton should exist and you can try to connect it.

  15. #15
    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

    Quote Originally Posted by mikro
    if you created the window in the designer you have to call setupUi( this ); first thing in your classes constructor.
    He's using Qt3, there is no such thing as setupUi() there.

  16. #16
    Join Date
    Apr 2006
    Location
    Erlangen, Germany
    Posts
    58
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect

    ooops. sorry, hadn't realized that.

Similar Threads

  1. many connect
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2006, 13:55
  2. [QT4 & XP] connect on QtreeView
    By incapacitant in forum Newbie
    Replies: 1
    Last Post: 2nd March 2006, 12:08
  3. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 19:06
  4. connect
    By mickey in forum Newbie
    Replies: 1
    Last Post: 25th February 2006, 19: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.