I’m trying to finish my project with Python and PyQt4 and I’m having an issue passing a QLineEdit variable through a function I made. The string should work as an url and when I pass it through my first argument, which tries to read the url and get its content, it throws me this error:
Traceback (most recent call last):
File "programa2.py", line 158, in on_link_clicked
download_mango(self.a, self.path2)
File "c:\Users\Poblet\ManGet\mango.py", line 19, in download_mango
urlContent = urllib2.urlopen(url).read() # We read the URL
File "c:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "c:\Python27\lib\urllib2.py", line 386, in open
protocol = req.get_type()
AttributeError: 'QString' object has no attribute 'get_type'
Which is triggered by the following action:
def on_link_clicked(self):
self.a = self.linkEdit.displayText()
download_mango(self.a, self.path2)
And I’m completely lost. Could it be a PyQt4 issue or something wrong with my function?
I appreciate your help.
You didn’t post enough code to justify your statement that
Looks like you are passing a QString into urlopen. Just wrap it in
str()and you should be OK.