{"id":322,"date":"2019-05-04T13:30:01","date_gmt":"2019-05-04T13:30:01","guid":{"rendered":"http:\/\/web.recologypower.com:9080\/?p=322"},"modified":"2019-09-08T14:27:53","modified_gmt":"2019-09-08T14:27:53","slug":"pyqt5-attributeerror-qgridlayout-object-has-no-attribute-setmargin","status":"publish","type":"post","link":"http:\/\/www.recologypower.com:9080\/?p=322","title":{"rendered":"PyQt5 AttributeError: &#8216;QGridLayout&#8217; object has no attribute &#8216;setMargin&#8217;"},"content":{"rendered":"<p>PyQt4\u548cPyQt5\u7248\u672c\u5dee\u5f02\u3002<\/p>\n<p>PyQt4\u91c7\u7528\uff1aQVBoxLayout\u7684setMargin\u65b9\u6cd5<\/p>\n<p>PyQt5\u91c7\u7528\uff1aQVBoxLayout\u7684setContentsMargins\u65b9\u6cd5<\/p>\n<p>&nbsp;<\/p>\n<p>\u9519\u8bef\u63d0\u793a\uff1a return QtGui.QApplication.translate(context, text, disambig)<br \/>\nAttributeError: module &#8216;PyQt5.QtGui&#8217; has no attribute &#8216;QApplication&#8217;<\/p>\n<p>\u4fee\u6539\uff1areturn QApplication.translate(context, text, disambig)<\/p>\n<p>\u539f\u56e0\uff1aPyQt4\u548cPyQt5\u7248\u672c\u5dee\u5f02\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u9519\u8bef\u63d0\u793a\uff1aNameError: name &#8216;unicode&#8217; is not defined<\/p>\n<p>\u4fee\u6539\uff1aPython2 \u7684unicode \u51fd\u6570\u5728 Python3 \u4e2d\u88ab\u547d\u540d\u4e3a str\u3002\u5728 Python3 \u4e2d\u4f7f\u7528 \u00b7str \u6765\u4ee3\u66ff Python2 \u4e2d\u7684 unicode.<\/p>\n<p>\u539f\u56e0\uff1aThere is no such name in Python 3, no. You are trying to run Python 2 code in Python 3. In Python 3, unicode has been renamed to str.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"slide-text-bg2\">\n<h3>PyQt4\u548cPyQt5\u7248\u672c\u5dee\u5f02\u3002 PyQ<\/h3>\n<\/div>\n<div class=\"flex-btn-div\"><a href=\"http:\/\/www.recologypower.com:9080\/?p=322\" class=\"btn1 flex-btn\">\u9605\u8bfb\u66f4\u591a<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,17],"tags":[],"_links":{"self":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/322"}],"collection":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322"}],"version-history":[{"count":4,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":326,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions\/326"}],"wp:attachment":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}