QThread



  • Hi,
    I am trying to capture the screenshots of webpage in qtbrowser and sent it to a remote machine on every event occurance like mouse event from remote machine and keyboard event in host machine.So I need a thread to start which should start on every event occurance and sent to a remote machine over QTcpSocket.I tried building the program with fancy browser.I used to save the frame in an image file as

    @QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
    image.fill(Qt::transparent);

    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
    frame->render(&painter);
    image.save(filename,"JPG")
    

    @

    I need to create a thread to do the above function and sent it over remote machine and wait for any other event to occur(keybord,mouse) ,if occured then process the event and again sent the changed screenshot to client.How can I start the thread in mainwindow.cpp to do the above function.I started the QTcpServer at beginning and when client connects i did QTcpSocket to read the events from remote and process the event and then start the thread.If any event from host machine occured also  I need to start the thread.How can I do this


  • I am not sure why you need a new thead for this. Qt is already event-based. What you would need is a slot which is connected to all the events you want to supervise and do your screenshot & sending-stuff there.

    But maybe I missed the point?



  • Hi,
    One big problem with a seperate thread is that it can not get or hold GUI elements! Only the main thread may control the GUI. So to utilize the sending thread you should use a signal/slot mechanism to give the data to the other thread.
    Within a custom TCPIP protocol package data you could issue a remote capture and send image command. The communication thread will call a slot to start the capture of the GUI element. When done the QImage should be transferred to the sending thread via signal/slot.
    Easy as that ;-)
    Maybe read about QtConcurrent for short threads and explenations about what Qt classes to chose for multithreading!


Log in to reply
 

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