1 Star 0 Fork 1

shiver/qt_phone_helper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tbtodaynews.cpp 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
JianBiHua 提交于 2019-03-12 11:26 . qt phone helper
#include "tbtodaynews.h"
#include "ui_tbtodaynews.h"
TBTodayNews::TBTodayNews(QWidget *parent) :
QWidget(parent),
ui(new Ui::TBTodayNews)
{
ui->setupUi(this);
webview = nullptr;
setBackgroundColor ();
optionPushButtons ();
//
showUrl ("http://zsall.mobilem.360.cn/html/todayhot3.html?sdkver=0&ver=2.5.1.1630");
}
void TBTodayNews::optionPushButtons () {
//
optionPushButton (ui->left, ":/images/web_left.png");
optionPushButton (ui->right, ":/images/web_right.png");
optionPushButton (ui->fresh, ":/images/web_fresh.png");
optionPushButton (ui->home, ":/images/web_home.png");
}
void TBTodayNews::showUrl (QString u) {
url = u;
createWebView ();
}
void TBTodayNews::createWebView () {
if (webview == nullptr) {
webview = new QWebEngineView(this);
ui->verticalLayout->addWidget (webview);
//
connect(webview, SIGNAL(urlChanged(const QUrl&)), this, SLOT(on_webview_urlchanged(const QUrl&)));
}
webview->load(QUrl(url));
}
void TBTodayNews::setBackgroundColor () {
ui->topWidget->setStyleSheet ("background-color:#F0F0F0;");
ui->mainWidget->setStyleSheet ("background-color:#E0E0E0;border: 1px solid #A0A0A0");
}
void TBTodayNews::optionPushButton (QPushButton * pushButton, QString icon) {
// QPalette palette;
// palette.setBrush(QPalette::Background, QPixmap(icon));
// pushButton->setAutoFillBackground(true);
// pushButton->setPalette (palette);
pushButton->setStyleSheet (QString("QPushButton{background-image:url(%1)}").arg (icon));
}
TBTodayNews::~TBTodayNews()
{
delete ui;
}
void TBTodayNews::on_home_clicked()
{
webview->load(QUrl(url));
}
void TBTodayNews::on_left_clicked()
{
webview->back ();
}
void TBTodayNews::on_right_clicked()
{
webview->forward ();
}
// 刷新
void TBTodayNews::on_fresh_clicked()
{
webview->reload ();
}
void TBTodayNews::on_webview_urlchanged(const QUrl& url) {
qDebug()<<"on_webview_urlchanged: " << url;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shiver/qt_phone_helper.git
git@gitee.com:shiver/qt_phone_helper.git
shiver
qt_phone_helper
qt_phone_helper
master

搜索帮助