[PySide] sending data from urllib2.urlopen().read() via signal corrupts in receiver

Renaud Talon renaudtalon at fusefx.com
Mon Oct 23 02:50:42 CEST 2017


If you’re talking about a QRunnable receiving data from another QRunnable you are correct. QRunnable can’t receive data through signals. I learned that the hard way recently.
You have to use QThread or Qt Concurent if you want to do that, see table called “Comparison of Solutions” here :

http://doc.qt.io/qt-5/threads-technologies.html


From: Frank Rueter | OHUfx<mailto:frank at ohufx.com>
Sent: Sunday, October 22, 2017 5:40 PM
To: pyside at qt-project.org<mailto:pyside at qt-project.org>
Subject: Re: [PySide] sending data from urllib2.urlopen().read() via signal corrupts in receiver

Interesting. I assumed you can't do that between different threads to I never tried it.
On 10/23/2017 05:36 AM, Erik Johansson wrote:
Had the same problem.

Solved it by creating a QImage and emitting that.

Cheers,
Erik

On Sun, Oct 22, 2017 at 11:19 AM, Frank Rueter | OHUfx <frank at ohufx.com<mailto:frank at ohufx.com>> wrote:
quick follow up:
I am now writing the files to a temp directory and only passing the respective path via the signal, but I'm still curious how I would do this without writing anything to disk.

Cheers,
frank

On 10/22/2017 09:18 PM, Frank Rueter | OHUfx wrote:
Hi,

I am downloading a few images in a separate thread using QRunnable.
To download I am just using urllib2.urlopen() like this:

[...]
    def run(self):
        imageData = urllib2.urlopen(self.url).read()
        print 'emitted:', imageData
        self.signals.receivedData.emit(imageData) # this signal is declared like this: QtCore.Signal(str)


However, the receiving slot is receiving nothing:

    def setPixmap(self, imageData):
        print 'received:', imageData
        pixmap = QtGui.QPixmap()
        pixmap.loadFromData(imageData)
        self.data['pixmap'] = pixmap


I guess this is too naive an approach to download image data in a separate thread?!

How can I fix this please?

Cheers,
frank

--
[ohufxLogo 50x50]<http://www.ohufx.com>

vfx compositing<http://ohufx.com/index.php/vfx-compositing> | workflow customisation and consulting<http://ohufx.com/index.php/vfx-customising>




_______________________________________________

PySide mailing list

PySide at qt-project.org<mailto:PySide at qt-project.org>

http://lists.qt-project.org/mailman/listinfo/pyside


_______________________________________________
PySide mailing list
PySide at qt-project.org<mailto:PySide at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/pyside



--

ERIK JOHANSSON
Pipeline TD

GOODBYE KANSAS STUDIOS
Rosenlundsgatan 40, 4th floor
118 53 Stockholm, Sweden

Ph: +46 8 556 990 00<tel:+46855699000>
www.goodbyekansas.com<http://www.goodbyekansas.com>





_______________________________________________

PySide mailing list

PySide at qt-project.org<mailto:PySide at qt-project.org>

http://lists.qt-project.org/mailman/listinfo/pyside


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20171023/8ff2ae57/attachment.html>


More information about the PySide mailing list