forked from feiyangqingyun/QWidgetDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc583c6
commit d9b38d7
Showing
9 changed files
with
532 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "frmzhtopy.h" | ||
#include "ui_frmzhtopy.h" | ||
#include "zhtopy.h" | ||
|
||
frmZhToPY::frmZhToPY(QWidget *parent) : QWidget(parent), ui(new Ui::frmZhToPY) | ||
{ | ||
ui->setupUi(this); | ||
ZhToPY::Instance()->loadPY(":/image/zhtopy.txt"); | ||
} | ||
|
||
frmZhToPY::~frmZhToPY() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void frmZhToPY::on_btnPY_clicked() | ||
{ | ||
ui->txtResult->setText(ZhToPY::Instance()->zhToPY(ui->txtChinese->text())); | ||
} | ||
|
||
void frmZhToPY::on_btnJP_clicked() | ||
{ | ||
ui->txtResult->setText(ZhToPY::Instance()->zhToJP(ui->txtChinese->text())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef FRMZHTOPY_H | ||
#define FRMZHTOPY_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Ui { | ||
class frmZhToPY; | ||
} | ||
|
||
class frmZhToPY : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit frmZhToPY(QWidget *parent = 0); | ||
~frmZhToPY(); | ||
|
||
private: | ||
Ui::frmZhToPY *ui; | ||
|
||
private slots: | ||
void on_btnPY_clicked(); | ||
void on_btnJP_clicked(); | ||
}; | ||
|
||
#endif // FRMZHTOPY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>frmZhToPY</class> | ||
<widget class="QWidget" name="frmZhToPY"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<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> | ||
</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="2"> | ||
<widget class="QPushButton" name="btnPY"> | ||
<property name="text"> | ||
<string>转全拼</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="labResult"> | ||
<property name="text"> | ||
<string>结果</string> | ||
</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> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma execution_character_set("utf-8") | ||
|
||
#include "frmzhtopy.h" | ||
#include <QApplication> | ||
#include <QTextCodec> | ||
|
||
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 _MSC_VER | ||
QTextCodec *codec = QTextCodec::codecForName("gbk"); | ||
#else | ||
QTextCodec *codec = QTextCodec::codecForName("utf-8"); | ||
#endif | ||
QTextCodec::setCodecForLocale(codec); | ||
QTextCodec::setCodecForCStrings(codec); | ||
QTextCodec::setCodecForTr(codec); | ||
#else | ||
QTextCodec *codec = QTextCodec::codecForName("utf-8"); | ||
QTextCodec::setCodecForLocale(codec); | ||
#endif | ||
|
||
frmZhToPY w; | ||
w.setWindowTitle("汉字转拼音"); | ||
w.show(); | ||
|
||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>image/zhtopy.txt</file> | ||
</qresource> | ||
</RCC> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef ZHTOPY_H | ||
#define ZHTOPY_H | ||
|
||
/** | ||
* 汉字转拼音类 作者:feiyangqingyun(QQ:517216493) 2019-2-16 | ||
* 1:汉字转拼音 | ||
* 2:汉字转拼音简拼 | ||
* 3:汉字转拼音首字母 | ||
*/ | ||
|
||
#include <QObject> | ||
#include <QStringList> | ||
|
||
#ifdef quc | ||
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0)) | ||
#include <QtDesigner/QDesignerExportWidget> | ||
#else | ||
#include <QtUiPlugin/QDesignerExportWidget> | ||
#endif | ||
|
||
class QDESIGNER_WIDGET_EXPORT ZhToPY : public QObject | ||
#else | ||
class ZhToPY : public QObject | ||
#endif | ||
|
||
{ | ||
Q_OBJECT | ||
public: | ||
static ZhToPY *Instance(); | ||
explicit ZhToPY(QObject *parent = 0); | ||
|
||
private: | ||
static QScopedPointer<ZhToPY> self; | ||
QStringList listPY; | ||
QStringList listJP; | ||
|
||
public: | ||
//载入拼音文件 | ||
void loadPY(const QString &fileName = "zhtopy.txt"); | ||
//汉字转拼音 | ||
QString zhToPY(const QString &chinese); | ||
//汉字转字母简拼 | ||
QString zhToJP(const QString &chinese); | ||
//汉字转首字母 | ||
QString zhToZM(const QString &chinese); | ||
}; | ||
|
||
#endif // ZHTOPY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2019-02-16T15:08:47 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
||
TARGET = zhtopy | ||
TEMPLATE = app | ||
DESTDIR = $$PWD/../bin | ||
CONFIG += warn_off | ||
|
||
SOURCES += main.cpp | ||
SOURCES += frmzhtopy.cpp | ||
SOURCES += zhtopy.cpp | ||
|
||
HEADERS += frmzhtopy.h | ||
HEADERS += zhtopy.h | ||
|
||
FORMS += frmzhtopy.ui | ||
|
||
RESOURCES += main.qrc |