#define WEATHER_GET_API_URL "http://wthrcdn.etouch.cn/weather_mini?city="
QString cityName = "广州";
QNetworkRequest weatherGetNRequest;
weatherGetNRequest.setUrl(QUrl(WEATHER_GET_API_URL + cityName));
QNetworkReply *newReply = NAManager->get(weatherGetNRequest);
connect(newReply, SIGNAL(finished()), this, SLOT(slotFinishedWeatherGetReply()));
4、查询其他地点的天气原理
由于开发板没有输入法,需要移植输入法比较麻烦,于是我想到了一种好用快捷,并且可以查询任意地点的方法.
方法就是通过地图。
点击搜索调用地图APP,地图可以提供一个经度,一个维度,返回给天气APP,天气APP就可以根据地图提供的地理信息,
1)首先,点击搜索图标:

2)进入地图APP后,把地图标记点拖动到想要的位置后,点击返回,地图会把当前的地理信息(经度纬度)保存到“p.info”文件里

3)得到地理位置信息后,通过逆地理API转化为城市信息,由于百度地图逆地理API试了好几次,许多地理位置不能转换,于是找到了高德地图API,非常好用
高德地图逆地理API:
https://lbs.amap.com/api/webservice/guide/api/georegeo
点击链接,查看使用方法,先注册,后申请一个AK就可以使用了,请求格式如下
http://restapi.amap.com/v3/geocode/regeo?output=json&location=116.310003,39.991957&key=<您的key>&radius=1000&extensions=all
4)发送请求后得到一个很长的json数据,我们只需要提取一个城市即可,这样逆地理处理就完成了,得到城市名之后,再传参给获取天气API就可以得到新地址的天气了
5)json数据在线解析网站:https://json.im/
获取到json数据后,可以利用数据解析更好的提取想要的数据
复制文档到网站,就可以很方便找到目标的位置

6)获取到城市信息后利用天气API,就可以得到该地的天气信息
点击返回,就查询到了赣州的天气

5、天气查询功能具体实现
1)在地图APP返回前获取地图位置
f_file.setFileName("p.info");
f_file.open(QIODevice::Append | QIODevice::Truncate);
QString point_msg = QString("%1\n%2").arg(east).arg(north);
f_file.write(point_msg.toUtf8().data());
f_file.close();
exit(1);
2)用天气APP打开地图APP
this->hide();
mypro->start("./QMap");
mypro->waitForFinished();
this->show();
QString file_n = "p.info";
QFile f_file;
f_file.setFileName(file_n);
f_file.open(QIODevice::ReadOnly);
QString east_n = f_file.readLine();
QString north_n = f_file.readLine();
f_file.close();
east = east_n.toDouble();
north = north_n.toDouble();
sendResquest();
3)逆地理获取城市名
给一个经维度信息(116.310003,39.991957),得到这个地址的城市名(北京市)
void MainWindow::sendResquest()
QString resq_msg =
QString("http://restapi.amap.com/v3/geocode/regeo?output=josn&location=%1,%2&key=f98d84de8b3b0bf7ac20c80d9775796b&radius=1000&extensions=all")
.arg(east).arg(north);
resquest.setUrl(QUrl(resq_msg.toUtf8().data()));
reply=manager->get(resquest);
connect(reply, &QIODevice::readyRead,this,&MainWindow::ready_Read_slots);
发送逆地理请求后,接收处理json数据,提取城市信息,并发送该城市的天气数据请求,获取到天气数据会自动更新显示界面的天气信息
void MainWindow::ready_Read_slots()
QString msg = reply->readAll();
msg = msg.remove("\n");
msg=msg.remove("\r");
QJsonDocument json = QJsonDocument::fromJson(msg.toUtf8());
QJsonObject obj = json.object();
city = obj.take("regeocode").toObject().take("addressComponent").toObject().take("city").toString();
QString cityName = city;
QNetworkRequest weatherGetNRequest;
weatherGetNRequest.setUrl(QUrl(WEATHER_GET_API_URL + cityName));
QNetworkReply *newReply = NAManager->get(weatherGetNRequest);
connect(newReply, SIGNAL(finished()), this, SLOT(slotFinishedWeatherGetReply()));
1、去除背景网站:
https://www.remove.bg/zh
可以去除照片的背景(最好是白底)
去除效果:(其他地方透明)

2、自定义按钮封装(按下可以有动画效果)
可以到哔哩哔哩上看黑马程序员2018视频有详细讲解

代码创建:
1)在工程下创建一个c++ class类,生成以下文件

2)编写代码
myPushButton.h
#ifndef MYPUSHBUTTON_H
#define MYPUSHBUTTON_H
#include<QPushButton>
#include<QPropertyAnimation>
#include<QString>
#include<QEvent>
#include<QMouseEvent>
#include <QObject>
#include <QWidget>
class myPushButton : public QPushButton
Q_OBJECT
public:
myPushButton(QString normal_path,QString press_path="",int pixwidth=10,int pixheight=10);
void zoom1();
void zoom2();
private:
QString normal_path;
QString press_path;
QPropertyAnimation* animation;
protected:
void mousePressEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e);
signals:
public slots:
#endif
myPushButton.cpp
#include "myPushButton.h"
#include <QDebug>
myPushButton::myPushButton(QString normal_path,QString press_path,int pixwidth,int pixheight)
this->normal_path=normal_path;
this->press_path=press_path;
QPixmap pix;
bool ret = pix.load(this->normal_path);
if(!ret)
qDebug()<<"图片加载失败";
return ;
this->setFixedSize(pixwidth,pixheight);
this->setStyleSheet( "QPushButton{border:0px;}" );
this->setIcon(pix);
this->setIconSize(QSize(pixwidth,pixheight));
this->setFocusPolicy(Qt::NoFocus);
animation = new QPropertyAnimation(this,"geometry");
void myPushButton::zoom1()
animation->setDuration(200);
animation->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
animation->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
void myPushButton::zoom2()
animation->setDuration(200);
animation->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
animation->setEndValue(QRect(this->x(),this->y()-10,this->width(),this->height()));
animation->setEasingCurve(QEasingCurve::InElastic);
animation->start();
void myPushButton::mousePressEvent(QMouseEvent *e)
if(this->press_path != "")
QPixmap pix;
bool ret = pix.load(this->press_path);
if(!ret)
qDebug()<<"图片加载失败";
return ;
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet("QPushButton{border:0px;}");
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
return QPushButton::mousePressEvent(e);
void myPushButton::mouseReleaseEvent(QMouseEvent *e)
if(this->press_path != "")
QPixmap pix;
bool ret = pix.load(this->normal_path);
if(!ret)
qDebug()<<"图片加载失败";
return ;
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet("QPushButton{border:0px;}");
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
return QPushButton::mouseReleaseEvent(e);
3)自定义封装按钮使用
#include "mypushButton.h"
myPushButton *next_button=new myPushButton(":/pic/next.png","",40,40);
next_button->setParent(this);
next_button->move(140,400);
connect(next_button,&myPushButton::clicked,[=](){
next_button->zoom1();
next_button->zoom2();
});
3、进度条样式
普通进度条样式
美化后的进度条样式

进度条样式利用QSS技术(QT StyleSheet)
#define MEDIASLIDER_STYLE "QSlider{\
border-color: #bcbcbc;\
QSlider::groove:horizontal {\
border: 1px solid #999999;\
height: 1px;\
margin: 0px 0; \
left: 5px; right: 5px;\
QSlider::handle:horizontal {\
border: 0px ;\
border-image: url(:icon/Resource/icon/handle.png);\
width: 20px; \
margin: -10px -7px -10px -7px; \
QSlider::add-page:horizontal{\
background: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 #bcbcbc, stop:0.25 #bcbcbc, stop:0.5 #bcbcbc, stop:1 #bcbcbc); \
QSlider::sub-page:horizontal{ \
background: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 #439cf3, stop:0.25 #439cf3, stop:0.5 #439cf3, stop:1 #439cf3); \
把样式设置到进度条上,就可以达到想要的效果,如果效果不理想可以深入学习QSS语法,QSS帮助文档:https://doc.qt.io/qt-5/stylesheet-syntax.html#style-rules
基于stm32c8t6的坡道行驶巡线小车(2020年TI杯大学生电子设计竞赛 C题)https://blog.csdn.net/mbs520/article/details/115438122
基于STM32F4的音乐播放器
https://blog.csdn.net/mbs520/article/details/111313042
基于STM32F4的电子阅读器(首创)
https://blog.csdn.net/mbs520/article/details/110817173
基于51单片机WiFi视频小车(首创)
https://blog.csdn.net/mbs520/article/details/109843972
基于51单片机蓝牙小车
https://blog.csdn.net/mbs520/article/details/109775964
基于MSP430 坡道行驶电动小车(2020年TI杯大学生电子设计竞赛 C题)
https://blog.csdn.net/mbs520/article/details/109090072
基于stm32f4的智能门锁系统
https://blog.csdn.net/mbs520/article/details/106987758
基于51单片机超声波测距小车
https://blog.csdn.net/mbs520/article/details/106599219
基于51单片机定时宠物喂食系统
https://blog.csdn.net/mbs520/article/details/108292187
基于QT5 Linux平台 停车场管理系统
https://blog.csdn.net/mbs520/article/details/113481824
基于QT5 Linux平台 车载系统
https://blog.csdn.net/mbs520/article/details/112873809
基于Linux系统 媒体播放器
https://blog.csdn.net/mbs520/article/details/107880118
基于Linux系统 语音识别、人机对话
https://blog.csdn.net/mbs520/article/details/113179224
基于Linux系统小钢琴程序(暂无博客)
https://download.csdn.net/download/mbs520/12798287
基于Linux系统 QQ通讯录管理系统(暂无博客)
眼下Linux基金会推出了基于Tizen 开源的车载系统平台Automotive Grade Linux (AGL), 眼下早期版本号的AGL已提供下载。
UI用HTML5和JavaScript编程.
http://linuxgizmos.com/automotive-grade-linux-group-releases-tizen-based-ivi-stack/
本项目的开发环境在 Windows 上的 QT, 运行在 GEC6818 开发板上。主要功能模块有:视频模块,音频模块,天气预报模块,地图显示模块
视频模块:通过 mplayer 实现对视频的播放、暂停、快进、后退,调用 QT里面的类 QDileDialog 实现添加视频文件,调用 QT 里面的类 QSlider 实现播放进度的显示、改变和音量的改变,调用 QT 的类 QListWidget 显示播放列表里面的文件
音频模块:在音频的播放、进度的显示、音量的改变、音频文件的显示方面上与视频模块类