重新改进支持Qt4.6-Qt6.1
This commit is contained in:
@@ -13,56 +13,90 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labChinese">
|
||||
<property name="text">
|
||||
<string>汉字</string>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtChinese">
|
||||
<property name="text">
|
||||
<string>飞扬青云 QQ:517216493</string>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="btnPY">
|
||||
<property name="text">
|
||||
<string>转全拼</string>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labResult">
|
||||
<property name="text">
|
||||
<string>结果</string>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtResult"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="btnJP">
|
||||
<property name="text">
|
||||
<string>转简拼</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="btnPY">
|
||||
<property name="text">
|
||||
<string>转全拼</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtChinese">
|
||||
<property name="text">
|
||||
<string>飞扬青云 QQ:517216493</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labChinese">
|
||||
<property name="text">
|
||||
<string>汉字</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtResult"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labResult">
|
||||
<property name="text">
|
||||
<string>结果</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="btnJP">
|
||||
<property name="text">
|
||||
<string>转简拼</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>59</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>203</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
|
||||
QApplication a(argc, argv);
|
||||
a.setFont(QFont("Microsoft Yahei", 9));
|
||||
|
||||
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
|
||||
#if _MSC_VER
|
||||
QTextCodec *codec = QTextCodec::codecForName("gbk");
|
||||
#else
|
||||
|
||||
@@ -271,24 +271,24 @@ QString ZhToPY::zhToPY(const QString &chinese)
|
||||
QString ZhToPY::zhToJP(const QString &chinese)
|
||||
{
|
||||
QString strChineseFirstPY = listJP.join("");
|
||||
if(chinese.length() == 0) {
|
||||
if (chinese.length() == 0) {
|
||||
return chinese;
|
||||
}
|
||||
|
||||
QString str;
|
||||
int index = 0;
|
||||
for(int i = 0; i < chinese.length(); i++) {
|
||||
for (int i = 0; i < chinese.length(); i++) {
|
||||
//若是字母或数字则直接输出
|
||||
ushort vChar = chinese.at(i).unicode() ;
|
||||
if((vChar >= 'a' && vChar <= 'z' ) || (vChar >= 'A' && vChar <= 'Z')) {
|
||||
if ((vChar >= 'a' && vChar <= 'z') || (vChar >= 'A' && vChar <= 'Z')) {
|
||||
str.append(chinese.at(i).toUpper());
|
||||
}
|
||||
|
||||
if((vChar >= '0' && vChar <= '9')) {
|
||||
if ((vChar >= '0' && vChar <= '9')) {
|
||||
str.append(chinese.at(i));
|
||||
} else {
|
||||
index = (int)vChar - 19968;
|
||||
if(index >= 0 && index < strChineseFirstPY.length()) {
|
||||
if (index >= 0 && index < strChineseFirstPY.length()) {
|
||||
str.append(strChineseFirstPY.at(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
|
||||
|
||||
TARGET = zhtopy
|
||||
TEMPLATE = app
|
||||
|
||||
Reference in New Issue
Block a user