Results 1 to 7 of 7

Thread: question on connect

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

    Default question on connect

    Hi, i coded this; it happend a strange thing: buttongroup contan several checkboxes
    when I check one, the SLOT is called; but when I uncheck one, the SLOT is called twice...
    Is there a QT reason for this? thanks
    Qt Code:
    1. connect(lightd->buttonGroupLL, SIGNAL(clicked(int)), this, SLOT(activeTabLight(int)));
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: question on connect

    I guess there is if your checkboxes are mutually exclusive and that none is checked when your app starts... Otherwise this might be a bug but I can't be sure without seeing your code...
    Current Qt projects : QCodeEdit, RotiDeCode

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

    Default Re: question on connect

    buttonGroupLL isn't exclusive and checkboxes are disable at startup....
    I put a printf inside activeTabLight and when I disable a checkbox, it starts twice...
    Regards

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

    Default Re: question on connect

    Hello everybdy. I'm understand the real problem; this is my code
    Every time the openLightDialog() is called, it seems the connect below is duplicated: the SLOT starts many time how I called openLightDialog(); eg if I call openLightDialog() 3 times, when a signal occurs, activeTabLight(int) is called 3 time instead one; I tried to put a disconnect at the end (but I don't like it). Furthermore, it seems that disconnect conficlits with a connect inside myLightDialog() constructor....
    Qt Code:
    1. myLightDialog::myLightDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
    2. :lightDialog (parent, name, modal, fl) {
    3. connect (this->buttonGroupLL, SIGNAL(clicked(int)), this, SLOT(pushButtonLight(int))); // with disconnect at the end, this doesn't work!!
    4. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void myMainForm::openLightDialog() {
    2. vector <QCheckBox*> cbl;
    3. cbl.push_back(lightd->checkBoxL0);
    4. ................................
    5. for (int i=0; i<8; i++)
    6. connect(cbl[i], SIGNAL(stateChanged(int)), this, SLOT(activeTabLight(int)));
    7. if(lightd->exec()){
    8. DoSomething();
    9. ......................
    10. }
    11. for (int i=0; i<8; i++) {
    12. cbl[i]->disconnect();
    13. }
    To copy to clipboard, switch view to plain text mode 
    How to do this? maybe Do I have to destroy that vector anywhere?
    thanks
    Last edited by mickey; 12th June 2006 at 16:30.
    Regards

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: question on connect

    Maybe you should make the connection in a different place in code?

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

    Default Re: question on connect

    yes, it's right; I put it in other place; but i don't understand a thing; the vector should be destroy at the end of this method...(?) and connect is aliving? What happened, please....
    Regards

  7. #7
    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: question on connect

    Quote Originally Posted by mickey
    the vector should be destroy at the end of this method...(?) and connect is aliving?
    That vector contains pointers and only those pointers will be removed --- objects they point to won't be deleted.

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. 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
  •  
Qt is a trademark of The Qt Company.