View Full Version : connect
mickey
19th July 2006, 15:48
hi, why do I have this console error?? thanks
//my is a pointer to MainForm class
//I'm inside MyWidget constructor
connect (my->pushButton21, SIGNAL (pressed()), this, SLOT (mySlot()) );
QObject::connect: Cannot connect (null)::pressed() to MyWidget::mySlot()
jacek
19th July 2006, 15:54
Maybe because my->pushButton21 is null?
mickey
19th July 2006, 15:58
ok. but why is it null? button21 is a button of mainform; how do I use it?
jacek
19th July 2006, 16:07
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?
mickey
19th July 2006, 16:53
hi, I don't understand qaht you want say.....the situation is this..
MyWidget::MyWidget( QWidget *parent, const char *name, const QGLWidget* shareWidget)
: QGLWidget ( parent, name, shareWidget){
my = (myMainForm*) this->topLevelWidget();
connect (w->pushButton21, SIGNAL (pressed()), this, SLOT (myStartTimer()) );
}
jacek
19th July 2006, 16:58
Could you post myMainForm constructor?
mickey
19th July 2006, 17:01
do u want this?
myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
: MainForm( parent, name, fl )
{
..............
}
jacek
19th July 2006, 17:09
do u want this?
Yes, do you initialize pushButton21 there?
mickey
19th July 2006, 18:19
Yes, do you initialize pushButton21 there?
what do you mean? I insert butt21 from designer....
jacek
19th July 2006, 18:23
I insert butt21 from designer....
In that case maybe this is wrong:
my = (myMainForm*) this->topLevelWidget();
What happens when you use dynamic_cast?
my = dynamic_cast< myMainForm*>( topLevelWidget() );
Q_CHECK_PTR( my );
mickey
19th July 2006, 18:50
a rutime error!!! and application is closed...
and without casting (my way) Q_CHECK_PTR( my ); doens't get any arror...
but my is:
myMainForm* my;
jacek
19th July 2006, 19:20
a rutime error!!! and application is closed...
This means that topLevelWidget() might return some other widget than myMainForm.
mickey
20th July 2006, 10:23
hi, using that bellow
myw = (myMainForm*) this->topLevelWidget();
it print the follow pointer
my_mainfom in myWidget 0012E388
mainfom this in MainForm 0012E388
my_mainfom this in myMainForm 0012E388
so myw in MyWidget point to mainForm.....have you any idea? thanks
mikro
24th July 2006, 22:29
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.
wysota
25th July 2006, 01:29
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.
mikro
2nd August 2006, 22:42
ooops. sorry, hadn't realized that.:o
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.