Results 1 to 16 of 16

Thread: connect

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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

Similar Threads

  1. many connect
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2006, 12:55
  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.