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

  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.