当前位置: 首页 > news >正文

河北路泰建设工程有限公司网站婚庆公司介绍

河北路泰建设工程有限公司网站,婚庆公司介绍,不同域名一样的网站,上传网站空间主要介绍Graphics View框架#xff0c;实现地图的浏览、放大、缩小#xff0c;以及显示各个位置的视图、场景和地图坐标 效果图: mapwidget.h #ifndef MAPWIDGET_H #define MAPWIDGET_H #include QLabel #include QMouseEvent #include QGraphicsView实现地图的浏览、放大、缩小以及显示各个位置的视图、场景和地图坐标 效果图: mapwidget.h #ifndef MAPWIDGET_H #define MAPWIDGET_H #include QLabel #include QMouseEvent #include QGraphicsViewclass MapWidget : public QGraphicsView { public:MapWidget();void readMap();QPointF mapToMap(QPointF); //实现场景坐标系与地图坐标之间的映射以获得某点的经纬度值public slots:void slotZoom(int);QPixmap map; protected:void drawBackground(QPainter *painter,const QRectF rect); //完成地图显示的功能void mouseMoveEvent(QMouseEvent * event);private:qreal zoom;QLabel *viewCoord;QLabel *sceneCoord;QLabel *mapCoord;double x1,x2;double y1,y2;};#endif // MAPWIDGET_Hmapwidget.cpp #include mapwidget.h #include QSlider #include QGridLayout #include QVBoxLayout #include QHBoxLayout #include QFile #include QGraphicsScene #include QTextStream #include math.h #include QLabel/* 1、setCacheMode(CacheBackground)这个属性控制view的那一部分缓存中QGraphicsView可以预存一些内容在QPixmap中 * 然后被绘制到viewpoint上这样做的目的是加速整体区域重绘的速度例如质地、倾斜度、和最初的混合背景可能重绘很缓慢 * 尤其是在一个变形的view中CacheBackground标志使能view的背景缓存例如 * QGraphicsView view; * view.setBackgroundBrush(QImage(:/images/backgroundtile.png)); * view.setCacheMode(QGraphicsView::CacheBackground); * 每次view转换后cache就无效了然而当滚动区域时候只有部分无效默认的没有使用cache * 2、setTickInterval(int)来设置发射信号的间隔一般都设置为1000ms就是1s发射一次 * 3、setScaledContents(bool)这个属性保存标签是否按这个图片的比例填满所用的可用空间默认false*/MapWidget::MapWidget() {//读取地图信息,包括地图的名称经纬度等readMap();zoom50;int widthmap.width();int heightmap.height();QGraphicsScene *scenenew QGraphicsScene(this);scene-setSceneRect(-width/2,-height/2,width,height);setScene(scene);setCacheMode(CacheBackground);//用于地图缩放的滑动条QSlider *slidernew QSlider;slider-setOrientation(Qt::Vertical);slider-setRange(1,100);slider-setTickInterval(10);slider-setValue(1);connect(slider,QSlider::valueChanged,[](int t_value){slotZoom(t_value);});;QLabel *zoominnew QLabel;zoomin-setScaledContents(true);zoomin-setPixmap(QPixmap(:/image/zoomin.jpg));zoomin-setFixedSize(30,30);QLabel *zoomoutnew QLabel;zoomout-setScaledContents(true );zoomout-setPixmap(QPixmap(:/image/zoomout.jpg));zoomout-setFixedSize(30,30);//坐标值显示区QLabel *label1new QLabel(QStringLiteral(QGraphicsView:));viewCoordnew QLabel;QLabel *label2new QLabel(QStringLiteral(QGraphicsScene:));sceneCoordnew QLabel;QLabel *label3new QLabel(QStringLiteral(map:));mapCoordnew QLabel;//坐标显示区布局QGridLayout *gridLayoutnew QGridLayout;gridLayout-addWidget(label1,0,0);gridLayout-addWidget(viewCoord,0,1);gridLayout-addWidget(label2,1,0);gridLayout-addWidget(sceneCoord,1,1);gridLayout-addWidget(label3,2,0);gridLayout-addWidget(mapCoord,2,1);gridLayout-setSizeConstraint(QLayout::SetFixedSize);QFrame *coordFramenew QFrame;coordFrame-setLayout(gridLayout);//坐标显示布局QVBoxLayout *coordLayoutnew QVBoxLayout;coordLayout-addWidget(coordFrame);coordLayout-addStretch();//缩放控制子布局QVBoxLayout *zoomlayoutnew QVBoxLayout;zoomlayout-addWidget(zoomin);zoomlayout-addWidget(slider);zoomlayout-addWidget(zoomout);//主布局QHBoxLayout *mainLayout new QHBoxLayout;mainLayout-addLayout(zoomlayout);mainLayout-addLayout(coordLayout);mainLayout-addStretch();mainLayout-setMargin(30);mainLayout-setSpacing(10);setLayout(mainLayout);setWindowTitle(QStringLiteral(Map Widget));setMinimumSize(600,400);} void MapWidget::readMap() //读取地图信息 {QString mapName;QFile mapFile(:/image/China.txt);int okmapFile.open((QIODevice::ReadOnly | QIODevice::Text)); //以只读方式打开此文件if(ok){QTextStream ts(mapFile);if(!ts.atEnd()){ts mapName;tsx1y1x2y2;}}mapFile.close();map.load(:/image/China.jpg); //将地图读取至私有变量map中}//根据缩放滑动条的当前值确定当前缩放的比例 void MapWidget::slotZoom(int value) {/** 检测valueslider改变得到的值与当前value值得大小比较* pow(x, y)表示x的y次方* slider改变的值大于zoom值时增加缩放比例* slider改变的值小于zoom值时减小缩放比例* scale(s, s)将当前的视图换为(s, s)*/qreal s;if(valuezoom) //放大{spow(1.01,(value-zoom));}else{spow(1/1.01,(zoom-value));}scale(s,s); //实现地图的缩放zoomvalue;}//以地图图片重绘场景的背景来实现地图显示 void MapWidget::drawBackground(QPainter *painter, const QRectF rect) {painter-drawPixmap(int(sceneRect().left()),int(sceneRect().top()),map); }//完成某点在坐标上的映射和显示 void MapWidget::mouseMoveEvent(QMouseEvent *event) {//QGraphicsView坐标QPoint viewpointevent-pos();viewCoord-setText(QString::number(viewpoint.x()),QString::number(viewpoint.y()));//QGraphicsScene坐标QPointF scenePointmapToScene(viewpoint);sceneCoord-setText(QString::number(scenePoint.x()),QString::number(scenePoint.y()));//地图坐标经纬度QPointF latLon mapToMap(scenePoint);mapCoord-setText(QString::number(latLon.x()),QString::number(latLon.y()));}QPointF MapWidget::mapToMap(QPointF p) {QPointF latLon;qreal wsceneRect().width();qreal hsceneRect().height();qreal lony1-((h/2p.y())*abs(y1-y2)/h);qreal laty1-((w/2p.x())*abs(x1-x2)/w);latLon.setX(lat);latLon.setY(lon);return latLon; }
http://www.hkea.cn/news/14580900/

相关文章:

  • 如何k掉网站邯郸小程序
  • 设计软件免费下载网站金阊苏州网站建设
  • 网站开发怎么进行数据库连接wordpress照片展示
  • 青岛城市建设档案馆网站团员登录系统智慧团建
  • 怎么做有趣视频网站wordpress如何做关键词和描述设置
  • 社交网站开发流程做网站公司在哪
  • 网站软文代写开发公司前期部岗位职责
  • 深圳做网站哪里最好汉中市住房和城乡建设局网站
  • 做网站开发的需求文档互动网站建设多少钱
  • 免费的信息发布平台哪个网站seo做的最好
  • 网站侧边 跟随 样式h5商城模板
  • 网站可以做哪些广告语网站代码用什么打开
  • 响应式网站建设流程成都网络优化公司排行榜
  • 如何设计网站导航怎么做电商新手入门
  • 免费建网站哪家好西安建站平台
  • 网站 app 公众号先做哪个网站tag标签功能实现
  • 石嘴山市建设局网站商品营销推广的方法有哪些
  • 怎么用网站后台做轮播图免费网站建设itcask
  • 顺义顺德网站建设网站开发找什么论文
  • 住房与城乡建设部网站特色小镇网站高中建设工具
  • 济南网站建设云华互动win8导航网站模板
  • 汕头市住房和城乡建设局网站制作相册的软件
  • 网站开发案例详解下载有原型怎么做网站
  • 天价索赔背后的平台版权对垒seo推广分析关键词的第一个步骤
  • 花生壳免费域名注册网站个人又什么办法做企业网站
  • 网站设计会计分录怎么做wordpress 插件 朋友圈
  • 网站内链设置wordpress作者信息插件
  • 什么叫网站企业建立企业网站有哪些优势?
  • 网站建设调查报告范文2022客翻番的推广方法
  • 做网站需要学会什么软件上海建设工程咨询网招聘