本文整理匯總了Python中qgis.PyQt.QtCore.QUrl方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QUrl方法的具體用法?Python QtCore.QUrl怎麽用?Python QtCore.QUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.PyQt.QtCore
的用法示例。
在下文中一共展示了QtCore.QUrl方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fetchNext
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def fetchNext(self):
if len(self.queue) == 0:
return
url = self.queue.pop(0)
self.log("fetchNext: %s" % url)
request = QNetworkRequest(QUrl(url))
request.setRawHeader("User-Agent", self.userAgent)
reply = QgsNetworkAccessManager.instance().get(request)
reply.finished.connect(self.replyFinishedSlot)
self.requestingUrls.append(url)
self.replies.append(reply)
return reply
示例2: request
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def request(self, url):
fetcher = QgsNetworkContentFetcher()
fetcher.fetchContent(QUrl(url))
evloop = QEventLoop()
fetcher.finished.connect(evloop.quit)
evloop.exec_(QEventLoop.ExcludeUserInputEvents)
fetcher.finished.disconnect(evloop.quit)
return fetcher.contentAsString()
示例3: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def __init__(self):
""" Contructor """
QDialog.__init__(self)
self.setupUi(self)
self.webView.setContextMenuPolicy(Qt.NoContextMenu)
self.webView.load(QUrl("https://all4gis.github.io/QGISFMV/"))
示例4: __sync_request
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def __sync_request(self, url):
_url = QUrl(url)
_request = QNetworkRequest(_url)
self.__replies.append(_request)
QgsNetworkAccessManager.instance().sslErrors.connect(self.__supress_ssl_errors)
_reply = QgsNetworkAccessManager.instance().get(_request)
# wait
loop = QEventLoop()
_reply.finished.connect(loop.quit)
loop.exec_()
_reply.finished.disconnect(loop.quit)
QgsNetworkAccessManager.instance().sslErrors.disconnect(self.__supress_ssl_errors)
loop = None
error = _reply.error()
if error != QNetworkReply.NoError:
raise Exception(error)
result_code = _reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
result = _reply.readAll()
self.__replies.append(_reply)
_reply.deleteLater()
if result_code in [301, 302, 307]:
redirect_url = _reply.attribute(QNetworkRequest.RedirectionTargetAttribute)
return self.__sync_request(redirect_url)
else:
return result
示例5: openURL
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def openURL(self):
QDesktopServices.openUrl(QUrl("https://qms.nextgis.com/create"))
示例6: canvasPressEvent
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 別名]
def canvasPressEvent(self, event):
'''Capture the coordinate when the mouse button has been released,
format it, and copy it to the clipboard.'''
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
if settings.externalMapShowLocation:
if self.marker is None:
self.marker = QgsVertexMarker(self.canvas)
self.marker.setIconSize(18)
self.marker.setPenWidth(2)
self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
self.marker.setCenter(pt)
else:
self.removeMarker()
button = event.button()
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
lat = pt4326.y()
lon = pt4326.x()
if settings.googleEarthMapProvider(button):
f = tempfile.NamedTemporaryFile(mode='w', suffix=".kml", delete=False)
f.write('<?xml version="1.0" encoding="UTF-8"?>')
f.write('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">')
f.write('<Document>')
f.write(' <name>QGIS Location</name>')
f.write(' <description>{:.8f}, {:.8f}</description>'.format(lon, lat))
f.write(' <Placemark>')
f.write(' <name>QGIS Location</name>')
f.write(' <Point>')
f.write(' <coordinates>{:.8f},{:.8f},0</coordinates>'.format(lon, lat))
f.write(' </Point>')
f.write(' </Placemark>')
f.write('</Document>')
f.write('</kml>')
f.close()
if platform.system() == 'Windows':
os.startfile(f.name)
else:
webbrowser.open(f.name)
self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in Google Earth" % (lat, lon), level=Qgis.Info, duration=3)
else:
mapprovider = settings.getMapProviderString(lat, lon, button)
url = QUrl(mapprovider).toString()
webbrowser.open(url, new=2)
self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in external map" % (lat, lon), level=Qgis.Info, duration=3)