Nominate our 2022 Qt Champions!

Need to code for printing odd and even numbers between 1 and 100 with two threads

  • I have a QWdiget class with two LIneEdits and a Pushbutton.

    When i click on Pushbutton, two theads have to start (each one for even /odd) and update their values in corresponding lineedits.

    I tried the code without locks...the odd linedit gets populated first then the even lineedit gets updated....(not parallel right).

    how to make it parallel update

  • Moderators

    what do you have so far?
    Basically do this:

    1. connect a slot to the clicked signal of the button
    2. in the slot start the 2 threads (there are multiple ways to create threads in Qt)
    3. connect each thread's (custom) signal to the QLineEdit::setText() slot

  • Lifetime Qt Champion

    Is it some kind of exercise or what is the point to use two threads for that?

Log in to reply