Results 1 to 5 of 5

Thread: Very strange thing

  1. #1
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Very strange thing

    In a slots function responded to click of a button,
    I changed the a value:
    value+=50;
    then emit a signal
    emit isChanged();
    in another slots function, I updated changed value in GUI like
    updateGUI(value);

    the project was built successfully,
    however, when I click the button, it shows +=100, not 50,
    anyone has any clue? thanks.

  2. #2
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Very strange thing

    Ideas:
    1. Your GUI automatically connect the button with the slot, if your slot is named the way Qt uses it. Check the Docs for automatic connections.
    2. Be somehow autorepeat takes place like in QAction when you enable auto repeat.
    3. Check when the slot and signal are used and which happen after which; one signal two slots invoked, signal,slot, signal, slot etc. It may give you a clue what is happening.
    4. Provide an example and someone will surely help you.

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  3. The following user says thank you to maverick_pol for this useful post:

    Sheng (22nd October 2008)

  4. #3
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Very strange thing

    Quote Originally Posted by maverick_pol View Post
    Ideas:
    1. Your GUI automatically connect the button with the slot, if your slot is named the way Qt uses it. Check the Docs for automatic connections.
    2. Be somehow autorepeat takes place like in QAction when you enable auto repeat.
    3. Check when the slot and signal are used and which happen after which; one signal two slots invoked, signal,slot, signal, slot etc. It may give you a clue what is happening.
    4. Provide an example and someone will surely help you.

    Kacper
    Thanks, I found the problem, I just write same connect function twice.
    It is interesting though, see, if I have two same connect function, how QT interpret it?
    It seems Qt generated two signals and slots responded twice, but I added mutex to lock the object and disable the button, it still +=100. any ideas?

  5. #4
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Very strange thing

    It seems you have doubled a connection or have a repeat signal.
    Still can't tell more without seeing the code.

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Very strange thing

    A signal is "generated" once, but gets "propagated" to all slots in sequence. If you have the same slot connected twice, it will be triggered twice.

  7. The following user says thank you to wysota for this useful post:

    Sheng (22nd October 2008)

Similar Threads

  1. Strange problems with QUdpSocket
    By montylee in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2008, 07:51
  2. strange ailment "Object moved to here"
    By s410i in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2008, 23:27
  3. Replies: 5
    Last Post: 11th March 2008, 13:38
  4. very strange behaviour
    By regix in forum Qt Programming
    Replies: 23
    Last Post: 20th July 2006, 17:38
  5. strange thing with a toolbar
    By mickey in forum Qt Programming
    Replies: 8
    Last Post: 19th July 2006, 21:16

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.