PDA

View Full Version : strange connect



mickey
18th June 2006, 12:12
I've problem: this connect get me a console error like as cannot connect check box to null::set(bool); but the SLOT starts; it works!Why?



FancyPopup::FancyPopup(myMainForm* parent, const char* name ):
QLabel( parent, name, WType_Popup ), _myw(parent){
connect (checkBox, SIGNAL(toggled(bool)), _myw, SLOT(set(bool)));


and why this connect get me a run time error:


connect (dial, SIGNAL(valueChanged(int)), _myw, SLOT(setValue(int)));

but this works:


connect (dial, SIGNAL(dialMoved(int)), _myw, SLOT(setValue(int)));

sunil.thaha
19th June 2006, 07:08
See if the _myw is null before u call the Connect

mickey
19th June 2006, 17:09
FancyPopup::FancyPopup(myMainForm* parent, const char* name ):
QLabel( parent, name, WType_Popup ), _myw(parent){

yes, _myw in null; but why??? I set its parent to myMainForm* in costructor how above. How can it be null?

sumsin
20th June 2006, 10:14
What you are passing in the constructor of the FancyPopup?

I think you are calling the constructor by default values and the default value for myMainForm* parent is zero.

Thats why _myw is null.

mickey
20th June 2006, 22:52
myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
: MainForm( parent, name, fl )
{
popup = new FancyPopup(this);

with this parent popup sould be myMainForm. true?

sumsin
21st June 2006, 04:30
with this parent popup sould be myMainForm. true?

yes. Now the parent of your FancyPopup is myMainForm, as you are passing 'this'.

mickey
21st June 2006, 14:26
OK! my code is that before! Why parent is null???

mickey
28th June 2006, 16:32
Anyone know this? thanks

jacek
28th June 2006, 21:13
Maybe you have two _myw variables and you initialize the first one, but use the other one?

mickey
29th June 2006, 14:05
the instance of popup is created in myMainForm but the connect are linked inside costructor of Popup;


FancyPopup::FancyPopup(QWidget* parent, const char* name ):
QLabel( parent, name, WType_Popup ){
_myw = (myMainForm*) parent;

with this above _myw was null......I putted connect inside costructor of myMainForm and works; but I still don't understand why didn't work first...
thanks

sumsin
30th June 2006, 10:16
As your FancyPopup is inherited from the QLabel and when you have declare the constructor of the FancyPopup in the header file, I think you have passed the defaults values for the arguments of the constructor.

Like this:



FancyPopup(QWidget* parent = 0, const char* name = 0 );


So when you try to create an instance of FancyPopup without arguments, it takes the default values. And thats why your parent is NULL in first case.

mickey
30th June 2006, 13:52
myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
: MainForm( parent, name, fl )
{
popup = new FancyPopup(this);


mmmm sorry but here above I created an instance of FancyPopup with argument 'this'; then how its parent is null? thanks