Results 1 to 12 of 12

Thread: strange connect

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

    Default strange connect

    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?

    Qt Code:
    1. FancyPopup::FancyPopup(myMainForm* parent, const char* name ):
    2. QLabel( parent, name, WType_Popup ), _myw(parent){
    3. connect (checkBox, SIGNAL(toggled(bool)), _myw, SLOT(set(bool)));
    To copy to clipboard, switch view to plain text mode 

    and why this connect get me a run time error:
    Qt Code:
    1. connect (dial, SIGNAL(valueChanged(int)), _myw, SLOT(setValue(int)));
    To copy to clipboard, switch view to plain text mode 
    but this works:
    Qt Code:
    1. connect (dial, SIGNAL(dialMoved(int)), _myw, SLOT(setValue(int)));
    To copy to clipboard, switch view to plain text mode 
    Last edited by mickey; 18th June 2006 at 14:15.
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: strange connect

    See if the _myw is null before u call the Connect
    We can't solve problems by using the same kind of thinking we used when we created them

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

    Default Re: strange connect

    Qt Code:
    1. FancyPopup::FancyPopup(myMainForm* parent, const char* name ):
    2. QLabel( parent, name, WType_Popup ), _myw(parent){
    To copy to clipboard, switch view to plain text mode 
    yes, _myw in null; but why??? I set its parent to myMainForm* in costructor how above. How can it be null?
    Last edited by mickey; 19th June 2006 at 21:46.
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    India
    Posts
    54
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: strange connect

    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.

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

    Default Re: strange connect

    Qt Code:
    1. myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
    2. : MainForm( parent, name, fl )
    3. {
    4. popup = new FancyPopup(this);
    To copy to clipboard, switch view to plain text mode 
    with this parent popup sould be myMainForm. true?
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    India
    Posts
    54
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: strange connect

    with this parent popup sould be myMainForm. true?
    yes. Now the parent of your FancyPopup is myMainForm, as you are passing 'this'.

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

    Default Re: strange connect

    OK! my code is that before! Why parent is null???
    Regards

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

    Default Re: strange connect

    Anyone know this? thanks
    Regards

  9. #9
    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: strange connect

    Maybe you have two _myw variables and you initialize the first one, but use the other one?

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

    Default Re: strange connect

    the instance of popup is created in myMainForm but the connect are linked inside costructor of Popup;
    Qt Code:
    1. FancyPopup::FancyPopup(QWidget* parent, const char* name ):
    2. QLabel( parent, name, WType_Popup ){
    3. _myw = (myMainForm*) parent;
    To copy to clipboard, switch view to plain text mode 
    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
    Regards

  11. #11
    Join Date
    Jan 2006
    Location
    India
    Posts
    54
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: strange connect

    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:

    Qt Code:
    1. FancyPopup(QWidget* parent = 0, const char* name = 0 );
    To copy to clipboard, switch view to plain text mode 

    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.

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

    Default Re: strange connect

    Quote Originally Posted by mickey
    Qt Code:
    1. myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
    2. : MainForm( parent, name, fl )
    3. {
    4. popup = new FancyPopup(this);
    To copy to clipboard, switch view to plain text mode 
    mmmm sorry but here above I created an instance of FancyPopup with argument 'this'; then how its parent is null? thanks
    Regards

Similar Threads

  1. many connect
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2006, 12:55
  2. connect on a popup
    By mickey in forum Qt Programming
    Replies: 2
    Last Post: 12th April 2006, 16:37
  3. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06
  4. [Qt 4.1] Strange behaviour with QTableView
    By fane in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 06:17

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.