Qt 語言切換

void Widget::on_lanageCoBox_currentTextChanged(QString text)
{

	if (text == QStringLiteral("簡體中文"))
	{
		if (m_translator->load("widget_zh.qm"))
		{
			qApp->installTranslator(m_translator);
			ui.lanageCoBox->disconnect(this);
			ui.retranslateUi(this);
			ui.lanageCoBox->setCurrentText(QStringLiteral("簡體中文"));
			connect(ui.lanageCoBox, SIGNAL(currentTextChanged(QString)), this, SLOT(on_lanageCoBox_currentTextChanged(QString)));
			SETLANAGE(false);
		/*	ui.label_19->setProperty("urgent", false);
			ui.label_19->setStyle(QApplication::style());*/
		}

	}
	else if (text == "English")
	{
		if (m_translator->load("widget_en.qm"))
		{
			qApp->installTranslator(m_translator);
			ui.lanageCoBox->disconnect(this);
			ui.retranslateUi(this);
			ui.lanageCoBox->setCurrentText(QStringLiteral("English"));
			connect(ui.lanageCoBox, SIGNAL(currentTextChanged(QString)), this, SLOT(on_lanageCoBox_currentTextChanged(QString)));
			SETLANAGE(true);
			//ui.label_19->setProperty("urgent", true);
			//ui.label_19->setStyle(QApplication::style());
		}
	}
}
#define  SETLANAGE(x) ui.lanageCoBox->setProperty("urgent", x);\
	ui.lanageCoBox->setStyle(QApplication::style());\
	ui.correctBtn->setProperty("urgent", x);\
	ui.correctBtn->setStyle(QApplication::style());\
	ui.dataBtn->setProperty("urgent", x); \
	ui.dataBtn->setStyle(QApplication::style());\
	ui.measureBtn->setProperty("urgent", x); \
	ui.measureBtn->setStyle(QApplication::style());\
	ui.reportBtn->setProperty("urgent", x); \
	ui.reportBtn->setStyle(QApplication::style());\
	ui.setBtn->setProperty("urgent", x); \
	ui.setBtn->setStyle(QApplication::style());\
	ui.ImageStatusLabel->setProperty("urgent", x); \
	ui.ImageStatusLabel->setStyle(QApplication::style());\
	ui.focusBtn->setProperty("urgent", x); \
	ui.focusBtn->setStyle(QApplication::style()); \
	ui.label_22->setProperty("urgent", x); \
	ui.label_22->setStyle(QApplication::style()); \
	ui.checkBox_2->setProperty("urgent", x); \
	ui.checkBox_2->setStyle(QApplication::style()); \
	ui.checkBox->setProperty("urgent", x); \
	ui.checkBox->setStyle(QApplication::style()); \
	m_isEng = x;\
	if(x){ui.tableWidget->setColumnWidth(0,120);ui.tableWidget->setColumnWidth(4, 71);}\
	else {ui.tableWidget->setColumnWidth(0,113);ui.tableWidget->setColumnWidth(4, 78);}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章