Signals and slot machines QT

advertisements

I have asked a number of different questions now all regarding one main issue in my program and still not solved it at all, I'm using threading to keep my UI from locking up, but basically it still does because apparently you can't do UI stuff in threads.

So I've been told to use custom signals and slots (not that any examples were given).

So from the documentation I've read I came up with this code:

.h

signals:

void paint_signal(double x, double y);

.cpp

  connect(this,SIGNAL(paint_signal(double x, double y)), this, SLOT(PaintSomething(x,y)));

the Paintsomething function is within the same class as all of this....

thread:

*future2 = QtConcurrent::run(this, &GUI::paintAll);

paint all emits the paint_signal and passes 2 doubles

emit paint_signal(x, y);

but I get this error which I just don't understand at all

 connect: No such signal GUI::paint_signal(double x, double y)


connect(this,
        SIGNAL(paint_signal(double, double)),
        this,
        SLOT(PaintSomething(x,y)));

Remove parameter names and it should work. If this one doesn't work this one will:

    connect(this,
        SIGNAL(paint_signal(double, double)),
        this,
        SLOT(PaintSomething(double,double)));

Let me know if this works out for you :)

Update

The idea is that you cannot use the UI in a thread, instead you emit signals from the thread to the UI. Because this answer probably gets you back to the beginning (and possibly a new question) here is a working example of how to emit signals from threads:

QT Signals to UI in a thread