#pragma execution_character_set("utf-8")
#include "widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent),trans(nullptr)
{
QLabel* label = new QLabel(QString::fromUtf8("widget_处理"));
label->setStyleSheet("QLabel{font:60px}");
QHBoxLayout* layoutMain = new QHBoxLayout();
this->setLayout(layoutMain);
//layoutMain->addWidget(label);
layoutMain->setContentsMargins(0,0,0,0);
QFrame *mainFrame = new QFrame();
layoutMain->addWidget(mainFrame);
QHBoxLayout* layoutMainFrame = new QHBoxLayout();
layoutMainFrame->setContentsMargins(0,0,0,0);
mainFrame->setLayout(layoutMainFrame);
//帮助
QFrame *helpFrame = new QFrame();
QHBoxLayout* layoutHMenu1 = new QHBoxLayout();
layoutHMenu1->setContentsMargins(0,0,0,0);
layoutHMenu1->setSpacing(0);
//1/打开帮助
m_btnOpenHelp = new QToolButton();
m_btnOpenHelp->setText(tr("打开帮助"));
m_btnOpenHelp->setMaximumWidth(60);
layoutHMenu1->addWidget(m_btnOpenHelp);
//帮助小分类
QLabel *lable1_1 = new QLabel(this);
lable1_1->setText(tr("帮助"));
lable1_1->setMaximumHeight(20);
lable1_1->setAlignment(Qt::AlignCenter);
QVBoxLayout* layoutVMenu1 = new QVBoxLayout();
layoutVMenu1->setContentsMargins(0,0,0,0);
layoutVMenu1->setSpacing(0);
layoutVMenu1->addLayout(layoutHMenu1);
layoutVMenu1->addWidget(lable1_1);
helpFrame->setLayout(layoutVMenu1);
layoutMainFrame->addWidget(helpFrame);
//关于
QFrame *aboutFrame = new QFrame();
QHBoxLayout* layoutHMenu2 = new QHBoxLayout();
layoutHMenu2->setContentsMargins(0,0,0,0);
layoutHMenu2->setSpacing(0);
//1/关于
m_btnOpenAbout = new QToolButton();
m_btnOpenAbout->setText(tr("关于"));
m_btnOpenAbout->setMaximumWidth(60);
layoutHMenu2->addWidget(m_btnOpenAbout);
m_btnTranslate = new QToolButton();
m_btnTranslate->setText(tr("翻译"));
QObject::connect(m_btnTranslate,SIGNAL(clicked(bool)),this,SLOT(on_btnTranslate_clicked(bool)));
m_btnTranslate->setMaximumWidth(60);
layoutHMenu2->addWidget(m_btnTranslate);
//关于小分类
QLabel *lable2_1 = new QLabel(this);
lable2_1->setText(tr("关于"));
lable2_1->setMaximumHeight(20);
lable2_1->setAlignment(Qt::AlignCenter);
QVBoxLayout* layoutVMenu2 = new QVBoxLayout();
layoutVMenu2->setContentsMargins(0,0,0,0);
layoutVMenu2->setSpacing(0);
layoutVMenu2->addLayout(layoutHMenu2);
layoutVMenu2->addWidget(lable2_1);
aboutFrame->setLayout(layoutVMenu2);
layoutMainFrame->addWidget(aboutFrame);
//最后加弹簧
QSpacerItem *spacer = new QSpacerItem(10, 20,
QSizePolicy::Expanding,
QSizePolicy::Minimum);
layoutMainFrame->addItem(spacer);
}
Widget::~Widget()
{
}
void Widget::on_btnTranslate_clicked(bool checked)
{
static bool isChinese = true;
if(isChinese)
{
qDebug()<<"isChinese="<<isChinese;
if(trans)
{
qApp->removeTranslator(trans);
delete trans;
}
QString appDirPath = QCoreApplication::applicationDirPath();
//QString fileName = appDirPath+"//translate1_cn.qm";
QString fileName = QString(":/translate/translate1_cn.qm");
trans=new QTranslator;
trans->load(fileName);
qApp->installTranslator(trans);
qApp->processEvents();
isChinese = false;
}
else
{
qDebug()<<"isChinese="<<isChinese;
if(trans)
{
qApp->removeTranslator(trans);
delete trans;
}
QString appDirPath = QCoreApplication::applicationDirPath();
QString fileName = QString(":/translate/translate1_en.qm");
//QString fileName = appDirPath+"//translate1_en.qm";
trans=new QTranslator;
trans->load(fileName);
qApp->installTranslator(trans);
qApp->processEvents();
isChinese = true;
}
//ui->retranslateUi(this);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
translate1.zip (13个子文件)
translate1
translate1.pro 1KB
widget.cpp 4KB
translate.cpp 1KB
translate.h 442B
translate
basic.ini 54B
translate1_cn.qm 171B
translate1_en.qm 257B
translate.qrc 148B
translate1_cn.ts 851B
translate1_en.ts 998B
main.cpp 347B
translate1.pro.user 23KB
widget.h 712B
共 13 条
- 1
资源评论
程序员如山石
- 粉丝: 1015
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功