#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);
}
![avatar](https://profile-avatar.csdnimg.cn/53efe29540444f0f88fc072847f0b30d_maokexu123.jpg!1)
程序员如山石
- 粉丝: 883
- 资源: 30
最新资源
- wwwwwwwwwwwwwwwwwww
- 三菱伺服MR-JE-C与三菱FX-5UPLC进行两轴CCLINK-Basic总线通信程序 控制模式:有回原点,定位控制,速度控
- 基于SSM的学生宿舍管理系统【项目源码+数据库脚本】(毕设)
- 基于龙贝格观测器的永磁同步电机无感FOC 1.采用龙伯格观测器提取电机反电势,使用PLL从反电势中获得转子位置和速度信息 2
- 微信小程序-简易计算器
- 模块化多电平变流器 MMC 的VSG控制 虚拟同步发电机控制 MATLAB–Simulink仿真模型 5电平三相MMC,采用VS
- 安卓案例代码\Android美颜相机
- 基于高频方波电压注入的永磁同步电机无感FOC 1.采用方波电压注入,减少了提取dq轴基频电流时LPF的使用,提高了系统的动态性能
- python3.13轮子文件dlib-19.24.6-cp313-cp313-win-amd64.whl
- 中台三问智能评估系统研发项目立项材料(1).pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)