qpython怎么打开文件_如何用QWebEngineView打开下载文件对话框?

这个弹出窗口是由浏览器生成的,在QWebEngine的情况下,我们必须创建它。首先,必须检测到指示下载的信号,该信号是来自QWebEngineProfile的downloadRequested。这个信号发送给我们一个处理下载的QWebEngineDownloadItem对象,在这个对象中,我们在QFileDialog的帮助下创建一个对话框窗口。对于这种情况,我们将创建一个自定义的QWebEnginePage,如下所示:

索引.html

FazMaraneyRGB_transparent_mosaic_group1

body {

margin: 0;

padding: 0;

}

body,

table,

tr,

td,

th,

div,

h1,

h2,

input {

font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif;

font-size: 11pt;

}

#map {

position: absolute;

top: 0;

bottom: 0;

width: 100%;

}

/* full size */

.ctl {

padding: 2px 10px 2px 10px;

background: white;

background: rgba(255, 255, 255, 0.9);

box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);

border-radius: 5px;

text-align: right;

}

.title {

font-size: 18pt;

font-weight: bold;

}

.src {

font-size: 10pt;

}

#delete,

#export {

position: absolute;

top: 100px;

right: 10px;

z-index: 100;

background: white;

color: black;

padding: 6px;

border-radius: 4px;

font-family: 'Helvetica Neue';

cursor: pointer;

font-size: 12px;

text-decoration: none;

}

#export {

top: 130px;

}

Delete Features

Export Features

/* **** Leaflet **** */

// Base layers

// .. OpenStreetMap

var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {

attribution: '© OpenStreetMap contributors'

});

// .. White background

var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg==");

// Overlay layers (TMS)

var lyr1 = L.tileLayer('./tiles/{z}/{x}/{y}.png', {

tms: true,

maxZoom: 22,

opacity: 0.9,

attribution: ""

});

// Map

var map = L.map('map', {

measureControl: true,

center: [-18.3604868606589, -52.694255477616245],

zoom: 22,

minZoom: 0,

maxZoom: 22,

layers: [osm]

});

lyr1.addTo(map);

//Geojson Layers

var basemaps = {

"OpenStreetMap": osm,

"Without background": white

}

var overlaymaps = {

"Layer 1": lyr1

}

// Title

var title = L.control();

title.onAdd = function(map) {

this._div = L.DomUtil.create('div', 'ctl title');

this.update();

return this._div;

};

title.update = function(props) {

this._div.innerHTML = "FazMaraneyRGB_transparent_mosaic_group1";

};

title.addTo(map);

// Note

var src = 'Generated by Hawkit';

var title = L.control({

position: 'bottomleft'

});

title.onAdd = function(map) {

this._div = L.DomUtil.create('div', 'ctl src');

this.update();

return this._div;

};

title.update = function(props) {

this._div.innerHTML = src;

};

title.addTo(map);

var featureGroup = L.featureGroup().addTo(map);

var drawControl = new L.Control.Draw({

edit: {

featureGroup: featureGroup

}

}).addTo(map);

map.on('draw:created', function(e) {

// Each time a feaute is created, it's added to the over arching feature group

featureGroup.addLayer(e.layer);

});

// on click, clear all layers

document.getElementById('delete').onclick = function(e) {

featureGroup.clearLayers();

}

document.getElementById('export').onclick = function(e) {

// Extract GeoJson from featureGroup

var data = featureGroup.toGeoJSON();

// Stringify the GeoJson

var convertedData = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(data));

// Create export

document.getElementById('export').setAttribute('href', 'data:' + convertedData);

document.getElementById('export').setAttribute('download', 'data.geojson');

}

// Add base layers

L.control.layers(basemaps, overlaymaps, {

collapsed: true

}).addTo(map);

// Fit to overlay bounds (SW and NE points with (lat, lon))

map.fitBounds([

[-18.36827062251916, -52.6871074784942],

[-18.35270287637126, -52.7014028427423]

]);

;和13;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值