简体   繁体   English

SetText TypeError Pyqt4

[英]SetText TypeError Pyqt4

I recently started creating a web browser when I started to run into some problems. 当我开始遇到一些问题时,我最近开始创建Web浏览器。

I defined the function 我定义了功能

self.addressbar

As so: 因此:

    self.AddressBar = QtGui.QLineEdit(self.tab)
    self.AddressBar.setGeometry(QtCore.QRect(50, 20, 721, 31))
    self.AddressBar.setObjectName(_fromUtf8("AddressBar"))

I later defined 我后来定义

 self.Tab1Web

As so: 因此:

    self.Tab1Web = QtWebKit.QWebView(self.tab)
    self.AddressBar.setText(_fromUtf8(self.Tab1Web.url()))
    self.Tab1Web.setGeometry(QtCore.QRect(0, 70, 1171, 621))
    self.Tab1Web.setUrl(QtCore.QUrl(_fromUtf8("http://www.google.ca/?gfe_rd=cr&ei=GDbtWOjwM6WC8Qf-rI3QBA")))
    self.Tab1Web.setObjectName(_fromUtf8("Tab1Web"))

My problem is that I get the TypeError: 我的问题是我收到TypeError:

self.AddressBar.setText(_fromUtf8(self.Tab1Web.url()))
TypeError: setText(self, object): argument 1 has unexpected type 'QUrl'

The problem is that I do not know how to solve this. 问题是我不知道如何解决这个问题。 Thanks in advance! 提前致谢!

Taken from 取自

http://pyqt.sourceforge.net/Docs/PyQt4/qlineedit.html#setText http://pyqt.sourceforge.net/Docs/PyQt4/qlineedit.html#setText

You should pass either a python string or pyqt QString. 您应该传递python字符串或pyqt QString。

Try: 尝试:

self.AddressBar.setText(self.Tab1Web.url().toString())

It should do the trick.... 它应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM