Results 1 to 5 of 5

Thread: Slots are called recursive or in infinite loop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Slots are called recursive or in infinite loop

    Hello,
    today I wanted to write a small tool that simply converts decimal to hex an vice versa as I type. Means: Every new digit in a QLineEdit instantly updates the converted number in the other lineEdit.
    The decimalLineEdits textChanged() signal is connected to a slot UpdateDecimalChanged().
    The hexLineEdits textChanged() signal is connected to a slot UpdateHexChanged().

    In UpdateDecimalChanged() the decimal number is converted to a hex representation string an put in the hexLineEdit via setText(). The other slot accordingly.

    But every setText() results in a new signal textChanged() which calls the slot, which updates the other lineEdit, which emit textChanged(), which calls the other slot, which updates the first lineEdit etc. etc.
    This goes on forever.

    Any idea how this infinite loop can be avoided?
    I would prefer to avoid the usage of a "Convert" button. As I wrote: "convert as I type" is my goal.
    Attached Images Attached Images

Similar Threads

  1. Replies: 7
    Last Post: 6th March 2008, 18:24
  2. Infinite loop - resize parent from child
    By bitChanger in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2006, 13:21
  3. is it possible to stay on a user defined infinite loop?
    By mahe2310 in forum Qt Programming
    Replies: 9
    Last Post: 24th March 2006, 14:29

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.