@ -0,0 +1,53 @@ |
|||
# ---> Qt |
|||
# C++ objects and libs |
|||
*.slo |
|||
*.lo |
|||
*.o |
|||
*.a |
|||
*.la |
|||
*.lai |
|||
*.so |
|||
*.so.* |
|||
*.dll |
|||
*.dylib |
|||
|
|||
# Qt-es |
|||
object_script.*.Release |
|||
object_script.*.Debug |
|||
*_plugin_import.cpp |
|||
/.qmake.cache |
|||
/.qmake.stash |
|||
*.pro.user |
|||
*.pro.user.* |
|||
*.qbs.user |
|||
*.qbs.user.* |
|||
*.moc |
|||
moc_*.cpp |
|||
moc_*.h |
|||
qrc_*.cpp |
|||
ui_*.h |
|||
*.qmlc |
|||
*.jsc |
|||
Makefile* |
|||
*build-* |
|||
*.qm |
|||
*.prl |
|||
|
|||
# Qt unit tests |
|||
target_wrapper.* |
|||
|
|||
# QtCreator |
|||
*.autosave |
|||
|
|||
# QtCreator Qml |
|||
*.qmlproject.user |
|||
*.qmlproject.user.* |
|||
|
|||
# QtCreator CMake |
|||
CMakeLists.txt.user* |
|||
|
|||
# QtCreator 4.8< compilation database |
|||
compile_commands.json |
|||
|
|||
# QtCreator local machine specific files for imported projects |
|||
*creator.user* |
@ -0,0 +1,51 @@ |
|||
#------------------------------------------------- |
|||
# |
|||
# Project created by QtCreator 2021-10-18T14:20:08 |
|||
# |
|||
#------------------------------------------------- |
|||
|
|||
QT += core gui |
|||
QT += serialport network |
|||
|
|||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
|||
|
|||
TARGET = QCPShow |
|||
TEMPLATE = app |
|||
|
|||
# The following define makes your compiler emit warnings if you use |
|||
# any feature of Qt which as been marked as deprecated (the exact warnings |
|||
# depend on your compiler). Please consult the documentation of the |
|||
# deprecated API in order to know how to port your code away from it. |
|||
DEFINES += QT_DEPRECATED_WARNINGS |
|||
|
|||
# You can also make your code fail to compile if you use deprecated APIs. |
|||
# In order to do so, uncomment the following line. |
|||
# You can also select to disable deprecated APIs only up to a certain version of Qt. |
|||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 |
|||
|
|||
|
|||
SOURCES += main.cpp\ |
|||
mainwidget.cpp \ |
|||
serial/serialport.cpp \ |
|||
ccwidgets/cqlineedit.cpp \ |
|||
ccwidgets/cqspinbox.cpp \ |
|||
ccwidgets/cqtextedit.cpp \ |
|||
ccwidgets/cqwidgetspinbox.cpp \ |
|||
util/commonutil.cpp |
|||
|
|||
HEADERS += mainwidget.h \ |
|||
serial/serialport.h \ |
|||
ccwidgets/cqlineedit.h \ |
|||
ccwidgets/cqspinbox.h \ |
|||
ccwidgets/cqtextedit.h \ |
|||
ccwidgets/cqwidgetspinbox.h \ |
|||
util/commonutil.h |
|||
|
|||
FORMS += mainwidget.ui |
|||
|
|||
RESOURCES += \ |
|||
resource.qrc |
|||
|
|||
DISTFILES += \ |
|||
.gitignore \ |
|||
ReadMe.md |
@ -0,0 +1,318 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE QtCreatorProject> |
|||
<!-- Written by QtCreator 4.2.1, 2021-10-18T14:21:25. --> |
|||
<qtcreator> |
|||
<data> |
|||
<variable>EnvironmentId</variable> |
|||
<value type="QByteArray">{fe03815e-74e2-457e-b60c-e66368cd4ce4}</value> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.ActiveTarget</variable> |
|||
<value type="int">0</value> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.EditorSettings</variable> |
|||
<valuemap type="QVariantMap"> |
|||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|||
<value type="QString" key="language">Cpp</value> |
|||
<valuemap type="QVariantMap" key="value"> |
|||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|||
</valuemap> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|||
<value type="QString" key="language">QmlJS</value> |
|||
<valuemap type="QVariantMap" key="value"> |
|||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|||
</valuemap> |
|||
</valuemap> |
|||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|||
<value type="int" key="EditorConfiguration.IndentSize">4</value> |
|||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|||
<value type="int" key="EditorConfiguration.MarginColumn">80</value> |
|||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value> |
|||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|||
<value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value> |
|||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value> |
|||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|||
<value type="int" key="EditorConfiguration.TabSize">8</value> |
|||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|||
</valuemap> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.PluginSettings</variable> |
|||
<valuemap type="QVariantMap"/> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.Target.0</variable> |
|||
<valuemap type="QVariantMap"> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.8.0 MinGW 32bit</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.8.0 MinGW 32bit</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.58.win32_mingw53_kit</value> |
|||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value> |
|||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> |
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> |
|||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Release</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> |
|||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Profile</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value> |
|||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value> |
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|||
</valuemap> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> |
|||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value> |
|||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value> |
|||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value> |
|||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value> |
|||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value> |
|||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|||
<value type="int">0</value> |
|||
<value type="int">1</value> |
|||
<value type="int">2</value> |
|||
<value type="int">3</value> |
|||
<value type="int">4</value> |
|||
<value type="int">5</value> |
|||
<value type="int">6</value> |
|||
<value type="int">7</value> |
|||
<value type="int">8</value> |
|||
<value type="int">9</value> |
|||
<value type="int">10</value> |
|||
<value type="int">11</value> |
|||
<value type="int">12</value> |
|||
<value type="int">13</value> |
|||
<value type="int">14</value> |
|||
</valuelist> |
|||
<value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QcpShow</value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/QtSpace/QcpShow/QcpShow.pro</value> |
|||
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value> |
|||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QcpShow.pro</value> |
|||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value> |
|||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> |
|||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> |
|||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|||
</valuemap> |
|||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|||
</valuemap> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.TargetCount</variable> |
|||
<value type="int">1</value> |
|||
</data> |
|||
<data> |
|||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|||
<value type="int">18</value> |
|||
</data> |
|||
<data> |
|||
<variable>Version</variable> |
|||
<value type="int">18</value> |
|||
</data> |
|||
</qtcreator> |
@ -0,0 +1,3 @@ |
|||
## 绿道窗口显示程序 |
|||
|
|||
//TODO |
@ -0,0 +1,18 @@ |
|||
#include "cqlineedit.h" |
|||
|
|||
CQLineEdit::CQLineEdit(QWidget *parent) : QLineEdit(parent) |
|||
{ |
|||
this->setFocusPolicy(Qt::StrongFocus); |
|||
} |
|||
|
|||
void CQLineEdit::focusInEvent(QFocusEvent *event) |
|||
{ |
|||
QLineEdit::focusInEvent(event); |
|||
emit GetFocus(); |
|||
} |
|||
|
|||
void CQLineEdit::focusOutEvent(QFocusEvent *event) |
|||
{ |
|||
QLineEdit::focusOutEvent(event); |
|||
emit LostFocus(this->text()); |
|||
} |
@ -0,0 +1,18 @@ |
|||
#ifndef CQLINEEDIT_H |
|||
#define CQLINEEDIT_H |
|||
|
|||
#include <QLineEdit> |
|||
|
|||
class CQLineEdit : public QLineEdit |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
explicit CQLineEdit(QWidget *parent = 0); |
|||
void focusInEvent(QFocusEvent *event); //覆盖这两个函数
|
|||
void focusOutEvent(QFocusEvent *event); |
|||
signals: |
|||
void GetFocus(); //获得焦点信号
|
|||
void LostFocus(const QString &); //失去焦点信号
|
|||
}; |
|||
|
|||
#endif // CQLINEEDIT_H
|
@ -0,0 +1,19 @@ |
|||
#include "cqspinbox.h" |
|||
|
|||
CQSpinBox::CQSpinBox(QWidget *parent) : QSpinBox(parent) |
|||
{ |
|||
// this->setFocusPolicy(Qt::StrongFocus);
|
|||
} |
|||
|
|||
void CQSpinBox::focusInEvent(QFocusEvent *event) |
|||
{ |
|||
QSpinBox::focusInEvent(event); |
|||
emit GetFocus(); |
|||
} |
|||
|
|||
void CQSpinBox::focusOutEvent(QFocusEvent *event) |
|||
{ |
|||
QSpinBox::focusOutEvent(event); |
|||
emit LostFocus(this->text()); |
|||
} |
|||
|
@ -0,0 +1,20 @@ |
|||
#ifndef CQSPINBOX_H |
|||
#define CQSPINBOX_H |
|||
|
|||
#include <QSpinBox> |
|||
#include <QKeyEvent> |
|||
|
|||
class CQSpinBox : public QSpinBox |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
explicit CQSpinBox(QWidget *parent = 0); |
|||
void focusInEvent(QFocusEvent *event); //覆盖这两个函数
|
|||
void focusOutEvent(QFocusEvent *event); |
|||
|
|||
signals: |
|||
void GetFocus(); //获得焦点信号
|
|||
void LostFocus(const QString &); //失去焦点信号
|
|||
}; |
|||
|
|||
#endif // CQLINEEDIT_H
|
@ -0,0 +1,18 @@ |
|||
#include "cqtextedit.h" |
|||
|
|||
CQTextEdit::CQTextEdit(QWidget *parent) : QTextEdit(parent) |
|||
{ |
|||
this->setFocusPolicy(Qt::StrongFocus); |
|||
} |
|||
|
|||
void CQTextEdit::focusInEvent(QFocusEvent *event) |
|||
{ |
|||
QTextEdit::focusInEvent(event); |
|||
emit GetFocus(); |
|||
} |
|||
|
|||
void CQTextEdit::focusOutEvent(QFocusEvent *event) |
|||
{ |
|||
QTextEdit::focusOutEvent(event); |
|||
emit LostFocus(this->toPlainText()); |
|||
} |
@ -0,0 +1,18 @@ |
|||
#ifndef CQTEXTEDIT_H |
|||
#define CQTEXTEDIT_H |
|||
|
|||
#include <QTextEdit> |
|||
|
|||
class CQTextEdit : public QTextEdit |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
explicit CQTextEdit(QWidget *parent = 0); |
|||
void focusInEvent(QFocusEvent *event); //覆盖这两个函数
|
|||
void focusOutEvent(QFocusEvent *event); |
|||
signals: |
|||
void GetFocus(); //获得焦点信号
|
|||
void LostFocus(const QString &); //失去焦点信号
|
|||
}; |
|||
|
|||
#endif // CQTEXTEDIT_H
|
@ -0,0 +1,44 @@ |
|||
#include "cqwidgetspinbox.h" |
|||
|
|||
CQWidgetSpinBox::CQWidgetSpinBox(QWidget *parent) : QWidget(parent) |
|||
{ |
|||
// this->setFocusPolicy(Qt::StrongFocus);
|
|||
// this->setStyleSheet(QString::fromUtf8("border:1px solid"));
|
|||
this->init(); |
|||
} |
|||
|
|||
void CQWidgetSpinBox::focusInEvent(QFocusEvent *event) |
|||
{ |
|||
QWidget::focusInEvent(event); |
|||
emit GetFocus(); |
|||
} |
|||
|
|||
void CQWidgetSpinBox::focusOutEvent(QFocusEvent *event) |
|||
{ |
|||
QWidget::focusOutEvent(event); |
|||
emit LostFocus(); |
|||
} |
|||
|
|||
void CQWidgetSpinBox::init() |
|||
{ |
|||
m_lineEdit = new QLineEdit; |
|||
m_toolButtonUp = new QToolButton; |
|||
m_toolButtonDown = new QToolButton; |
|||
m_hLayout = new QHBoxLayout; |
|||
m_vLayout = new QVBoxLayout; |
|||
|
|||
// m_lineEdit->setStyleSheet("color: rgb(255, 255, 255);font: 10pt 'Adobe 黑体 Std R'';");
|
|||
// m_lineEdit->setFixedSize(60,20);;
|
|||
m_toolButtonUp->setFixedSize(15,11); |
|||
m_toolButtonDown->setFixedSize(15,11); |
|||
m_vLayout->addWidget(m_toolButtonUp); |
|||
m_vLayout->addWidget(m_toolButtonDown); |
|||
m_hLayout->addWidget(m_lineEdit); |
|||
m_hLayout->addLayout(m_vLayout); |
|||
setContentsMargins(0,0,0,0); |
|||
m_vLayout->setSpacing(0); |
|||
m_vLayout->setMargin(0); |
|||
m_hLayout->setSpacing(0); |
|||
m_hLayout->setMargin(0); |
|||
setLayout(m_hLayout); |
|||
} |
@ -0,0 +1,36 @@ |
|||
#ifndef CQWIDGETSPINBOX_H |
|||
#define CQWIDGETSPINBOX_H |
|||
|
|||
#include <QWidget> |
|||
#include <QHBoxLayout> |
|||
#include <QVBoxLayout> |
|||
#include <QLineEdit> |
|||
#include <QToolButton> |
|||
|
|||
class CQWidgetSpinBox : public QWidget |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
explicit CQWidgetSpinBox(QWidget *parent = 0); |
|||
|
|||
void focusInEvent(QFocusEvent *event); //覆盖这两个函数
|
|||
void focusOutEvent(QFocusEvent *event); |
|||
void setText(QString s); |
|||
QString text(); |
|||
|
|||
private: |
|||
QLineEdit *m_lineEdit; |
|||
QToolButton *m_toolButtonUp, *m_toolButtonDown; |
|||
QHBoxLayout *m_hLayout; |
|||
QVBoxLayout *m_vLayout; |
|||
|
|||
void init(); |
|||
|
|||
signals: |
|||
void GetFocus(); //获得焦点信号
|
|||
void LostFocus(); //失去焦点信号
|
|||
void UpClicked(); |
|||
void DownClicked(); |
|||
}; |
|||
|
|||
#endif // CQWIDGETSPINBOX_H
|
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 180 B |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 21 KiB |
@ -0,0 +1,11 @@ |
|||
#include "mainwidget.h" |
|||
#include <QApplication> |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
QApplication a(argc, argv); |
|||
MainWidget w; |
|||
w.show(); |
|||
|
|||
return a.exec(); |
|||
} |
@ -0,0 +1,14 @@ |
|||
#include "mainwidget.h" |
|||
#include "ui_mainwidget.h" |
|||
|
|||
MainWidget::MainWidget(QWidget *parent) : |
|||
QWidget(parent), |
|||
ui(new Ui::MainWidget) |
|||
{ |
|||
ui->setupUi(this); |
|||
} |
|||
|
|||
MainWidget::~MainWidget() |
|||
{ |
|||
delete ui; |
|||
} |
@ -0,0 +1,22 @@ |
|||
#ifndef MAINWIDGET_H |
|||
#define MAINWIDGET_H |
|||
|
|||
#include <QWidget> |
|||
|
|||
namespace Ui { |
|||
class MainWidget; |
|||
} |
|||
|
|||
class MainWidget : public QWidget |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit MainWidget(QWidget *parent = 0); |
|||
~MainWidget(); |
|||
|
|||
private: |
|||
Ui::MainWidget *ui; |
|||
}; |
|||
|
|||
#endif // MAINWIDGET_H
|
@ -0,0 +1,20 @@ |
|||
<ui version="4.0"> |
|||
<class>MainWidget</class> |
|||
<widget class="QWidget" name="MainWidget" > |
|||
<property name="geometry" > |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>400</width> |
|||
<height>300</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle" > |
|||
<string>MainWidget</string> |
|||
</property> |
|||
</widget> |
|||
<layoutDefault spacing="6" margin="11" /> |
|||
<pixmapfunction></pixmapfunction> |
|||
<resources/> |
|||
<connections/> |
|||
</ui> |
@ -0,0 +1,5 @@ |
|||
<RCC> |
|||
<qresource prefix="/"> |
|||
<file>image/header.png</file> |
|||
</qresource> |
|||
</RCC> |
@ -0,0 +1,149 @@ |
|||
#include "serialport.h" |
|||
#include "util/commonutil.h" |
|||
#include <QtCore> |
|||
|
|||
SerialPort::SerialPort(QObject *parent) |
|||
:QObject(parent) |
|||
{ |
|||
m_serial = Q_NULLPTR; |
|||
m_connected = false; |
|||
m_rbuffer.clear(); |
|||
m_wbuffer.clear(); |
|||
m_currentPortName = ""; |
|||
m_currentBaudRate = ""; |
|||
} |
|||
|
|||
SerialPort::~SerialPort(){} |
|||
|
|||
/**
|
|||
* 8N1 (8个数据位,1个停止位,无校验) |
|||
* @brief SerialPort::openSerialPort |
|||
* @param serialName |
|||
* @param baudrate |
|||
*/ |
|||
|
|||
#if 0 |
|||
bool SerialPort::openSerialPort(QString serialName, quint32 baudrate) |
|||
{ |
|||
qDebug() << "QSeriaport Attempting connect to " << serialName << "," << baudrate; |
|||
//如果已经打开,先执行关闭操作
|
|||
disConnected(); |
|||
|
|||
//记录当前正在使用的串口信息
|
|||
m_currentPortName = serialName; |
|||
m_currentBaudRate = QString::number(baudrate); |
|||
|
|||
//设置串口属性,并且打开
|
|||
m_serial = new QSerialPort(); |
|||
//connect(m_serial,SIGNAL(readyRead()),this,SLOT(readData));
|
|||
connect(m_serial,&QSerialPort::readyRead,this,&SerialPort::readData); |
|||
connect(m_serial,SIGNAL(error(QSerialPort::SerialPortError)),this, |
|||
SLOT(onError(QSerialPort::SerialPortError))); |
|||
|
|||
m_serial->setPortName((serialName)); |
|||
m_serial->setBaudRate(baudrate); |
|||
m_serial->setDataBits(QSerialPort::Data8); |
|||
m_serial->setParity(QSerialPort::NoParity); |
|||
m_serial->setStopBits(QSerialPort::OneStop); |
|||
m_serial->setFlowControl(QSerialPort::NoFlowControl); |
|||
|
|||
if(!m_serial->open(QIODevice::ReadWrite)){ |
|||
qCritical() << "Open Serial failed: " << m_serial->errorString(); |
|||
return false; |
|||
} |
|||
|
|||
m_connected = true; |
|||
qDebug() << "QSerialPort connected to " << serialName << "," << baudrate; |
|||
return true; |
|||
} |
|||
#else |
|||
bool SerialPort::openSerialPort(QString serialName, quint32 baudrate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopbits, QSerialPort::Parity parity, QSerialPort::FlowControl flowControl) |
|||
{ |
|||
qDebug() << "QSeriaport Attempting connect to " << serialName << "," << baudrate; |
|||
//如果已经打开,先执行关闭操作
|
|||
disConnected(); |
|||
|
|||
//记录当前正在使用的串口信息
|
|||
m_currentPortName = serialName; |
|||
m_currentBaudRate = QString::number(baudrate); |
|||
|
|||
//设置串口属性,并且打开
|
|||
m_serial = new QSerialPort(); |
|||
//connect(m_serial,SIGNAL(readyRead()),this,SLOT(readData));
|
|||
connect(m_serial,&QSerialPort::readyRead,this,&SerialPort::readData); |
|||
connect(m_serial,SIGNAL(error(QSerialPort::SerialPortError)),this, |
|||
SLOT(onError(QSerialPort::SerialPortError))); |
|||
|
|||
m_serial->setPortName((serialName)); |
|||
m_serial->setBaudRate(baudrate); |
|||
m_serial->setDataBits(dataBits); |
|||
m_serial->setParity(parity); |
|||
m_serial->setStopBits(stopbits); |
|||
m_serial->setFlowControl(flowControl); |
|||
// if(dataBits == QSerialPort::Data6){
|
|||
// qDebug()<<"Data6";
|
|||
// }
|
|||
|
|||
if(!m_serial->open(QIODevice::ReadWrite)){ |
|||
qCritical() << "Open Serial failed: " << m_serial->errorString(); |
|||
return false; |
|||
} |
|||
|
|||
m_connected = true; |
|||
qDebug() << "QSerialPort connected to " << serialName << "," << baudrate; |
|||
return true; |
|||
} |
|||
#endif |
|||
void SerialPort::disConnected() |
|||
{ |
|||
m_connected = false; |
|||
if(m_serial != Q_NULLPTR) |
|||
{ |
|||
if(m_serial->isOpen()){ |
|||
m_serial->close(); |
|||
} |
|||
m_serial->deleteLater(); |
|||
m_serial = Q_NULLPTR; |
|||
qDebug() << "disconnect from " << m_currentPortName << "," << m_currentBaudRate; |
|||
} |
|||
} |
|||
|
|||
bool SerialPort::isConnected() |
|||
{ |
|||
return m_connected; |
|||
} |
|||
|
|||
qint64 SerialPort::writeData(QByteArray &data) |
|||
{ |
|||
if(m_connected == false) |
|||
{ |
|||
return 0; |
|||
} |
|||
//write本身并不保证将数据全部写入,它只返回实际写入的字节数
|
|||
qint64 total = data.size(), writed = 0,n = 0; |
|||
while(writed < total) |
|||
{ |
|||
if((n = m_serial->write(data.mid(writed))) < 0){ |
|||
break; |
|||
} |
|||
writed += n; |
|||
} |
|||
qDebug() << QDateTime::currentMSecsSinceEpoch() << " " << "Serial send: " << writed << "," << CommonUtil::ByteArrayToHexString(data); |
|||
return writed; |
|||
} |
|||
|
|||
void SerialPort::readData() |
|||
{ |
|||
QByteArray ba = m_serial->readAll(); |
|||
emit serialReadData(ba); |
|||
//添加协议
|
|||
//qDebug() << ba;
|
|||
} |
|||
|
|||
void SerialPort::onError(QSerialPort::SerialPortError error) |
|||
{ |
|||
if(error != QSerialPort::NoError) |
|||
{ |
|||
qCritical() << "SerialError:" << m_serial->errorString(); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
#ifndef SERIALPORT_H |
|||
#define SERIALPORT_H |
|||
|
|||
#include <QSerialPort> |
|||
|
|||
/**
|
|||
* 串口通讯 |
|||
* @brief The SerialPort class |
|||
*/ |
|||
class SerialPort : public QObject |
|||
{ |
|||
Q_OBJECT |
|||
public: |
|||
SerialPort(QObject *parent = 0); |
|||
~SerialPort(); |
|||
private: |
|||
QString m_currentPortName; //当前串口名
|
|||
QString m_currentBaudRate; //当前串口波特率
|
|||
QSerialPort *m_serial; //Qt串口对象
|
|||
bool m_connected; //是否连接标志
|
|||
QByteArray m_rbuffer; //读缓冲区
|
|||
QByteArray m_wbuffer; //写缓冲区
|
|||
public: |
|||
bool openSerialPort(QString serialName,quint32 baudrate); |
|||
bool openSerialPort(QString serialName, quint32 baudrate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopbits, QSerialPort::Parity parity, QSerialPort::FlowControl flowControl); |
|||
void disConnected(); |
|||
bool isConnected(); |
|||
public slots: |
|||
void onError(QSerialPort::SerialPortError error); |
|||
void readData(); |
|||
qint64 writeData(QByteArray &data); |
|||
signals: |
|||
void serialReadData(QByteArray &data); |
|||
}; |
|||
|
|||
#endif // SERIALPORT_H
|
@ -0,0 +1,233 @@ |
|||
#include "commonutil.h" |
|||
#include <QNetworkInterface> |
|||
#include <QList> |
|||
#include <QDataStream> |
|||
|
|||
CommonUtil::CommonUtil() |
|||
{ |
|||
|
|||
} |
|||
|
|||
QByteArray CommonUtil::HexStringToByteArray(QString HexString) |
|||
{ |
|||
bool ok; |
|||
QByteArray ret; |
|||
HexString = HexString.trimmed(); |
|||
HexString = HexString.simplified(); |
|||
QStringList sl = HexString.split(" "); |
|||
|
|||
foreach (QString s, sl) { |
|||
if(!s.isEmpty()) { |
|||
char c = s.toInt(&ok,16)&0xFF; |
|||
if(ok){ |
|||
ret.append(c); |
|||
}else{ |
|||
qDebug()<<"非法的16进制字符:"<<s; |
|||
} |
|||
} |
|||
} |
|||
return ret; |
|||
} |
|||
|
|||
QString CommonUtil::ByteArrayToHexString(const QByteArray &ba) |
|||
{ |
|||
//QDataStream out(&ba,QIODevice::ReadWrite); //将str的数据 读到out里面去
|
|||
QDataStream out(ba); //将str的数据 读到out里面去
|
|||
QString buf; |
|||
while(!out.atEnd()) |
|||
{ |
|||
qint8 outChar = 0; |
|||
out >> outChar; //每次一个字节的填充到 outchar
|
|||
QString str = QString("%1").arg(outChar & 0xFF,2,16,QLatin1Char('0')).toUpper() + QString(" "); //2 字符宽度
|
|||
buf += str; |
|||
} |
|||
return buf; |
|||
} |
|||
|
|||
QString CommonUtil::ByteArrayToNonZeroString(const QByteArray &ba) |
|||
{ |
|||
QDataStream out(ba); //将str的数据 读到out里面去
|
|||
QString buf; |
|||
while(!out.atEnd()) |
|||
{ |
|||
qint8 outChar = 0; |
|||
out >> outChar; //每次一个字节的填充到 outchar
|
|||
QString str = outChar != 0 ? QString(QChar(outChar)) : "\\0"; |
|||
buf += str; |
|||
} |
|||
return buf; |
|||
} |
|||
|
|||
|
|||
QByteArray CommonUtil::quint8ArrToQByteArray(quint8 *arr,int lengths) |
|||
{ |
|||
QByteArray ba; |
|||
for(int i=0;i<lengths;i++) |
|||
{ |
|||
ba[i] = arr[i]; |
|||
} |
|||
return ba; |
|||
} |
|||
|
|||
#define I_1pA (1) |
|||
#define I_1nA (I_1pA * 1000) |
|||
#define I_1uA (I_1nA * 1000) |
|||
#define I_1mA (I_1uA * 1000) |
|||
|
|||
QString CommonUtil::i_pA_2_text(unsigned int iPA) |
|||
{ |
|||
qint64 ipa = (qint64)iPA; |
|||
if(ipa >= I_1mA) |
|||
{ |
|||
return QString("%1mA").arg(ipa * 100 / I_1mA / 100.0); |
|||
} |
|||
else if(ipa >= I_1uA) |
|||
{ |
|||
return QString("%1uA").arg(ipa * 100 / I_1uA / 100.0); |
|||
} |
|||
else if(ipa >= I_1nA) |
|||
{ |
|||
return QString("%1nA").arg(ipa * 100 / I_1nA / 100.0); |
|||
} |
|||
else if(ipa >= I_1pA) |
|||
{ |
|||
return QString("%1pA").arg(ipa * 100 / I_1pA / 100.0); |
|||
} |
|||
return "0"; |
|||
} |
|||
|
|||
void CommonUtil::crc16(quint8 crc[], quint8 data[],int pos, int len) |
|||
{ |
|||
int wcrc = 0xFFFF;// 预置16位crc寄存器,初值全部为1
|
|||
int temp;// 定义中间变量
|
|||
int i = 0, j = 0, k = pos;// 定义计数
|
|||
|
|||
for (i = 0; i < len; i++)// 循环计算每个数据
|
|||
{ |
|||
temp = (data[k] & 0xFF);// 将八位数据与crc寄存器亦或
|
|||
k++;// 指针地址增加,指向下个数据
|
|||
wcrc ^= temp;// 将数据存入crc寄存器
|
|||
for (j = 0; j < 8; j++)// 循环计算数据的
|
|||
{ |
|||
if ((wcrc & 0x0001) == 1)// 判断右移出的是不是1,如果是1则与多项式进行异或。
|
|||
{ |
|||
wcrc >>= 1;// 先将数据右移一位
|
|||
wcrc ^= 0XA001;// 与上面的多项式进行异或
|
|||
} else// 如果不是1,则直接移出
|
|||
{ |
|||
wcrc >>= 1;// 直接移出
|
|||
} |
|||
} |
|||
} |
|||
temp = wcrc;// crc的值
|
|||
crc[0] = wcrc & 0xFF; // crc的低八位
|
|||
crc[1] = (wcrc >> 8) & 0xFF; // crc的高八位
|
|||
} |
|||
|
|||
|
|||
//判断是否大端字节序
|
|||
int CommonUtil::isBigEndianOrder() |
|||
{ |
|||
int iVal = 1; |
|||
char *pChar = (char*)(&iVal); |
|||
if(*pChar == 1) //低字节在低地址(小端)
|
|||
return false; |
|||
return true; //(0x00000001) 低字节在高地址(大端) Aix采用的是大端法
|
|||
} |
|||
|
|||
#ifdef Q_OS_WIN |
|||
quint32 CommonUtil::Lc_ntohl(quint32 data) |
|||
{ |
|||
quint32 res = 0; |
|||
if(data == 0 || isBigEndianOrder()){ |
|||
res = data; |
|||
}else{ |
|||
res = (((data >> 0) & 0xFF) << 24) | (((data >> 8) & 0xFF) << 16) | (((data >> 16) & 0xFF) << 8) | (((data >> 24) & 0xFF) << 0); |
|||
} |
|||
return res; |
|||
} |
|||
|
|||
quint32 CommonUtil::Lc_htonl(quint32 data) |
|||
{ |
|||
quint32 res = 0; |
|||
if(data == 0 || isBigEndianOrder()){ |
|||
res = data; |
|||
}else{ |
|||
res = (((data >> 0) & 0xFF) << 24) | (((data >> 8) & 0xFF) << 16) | (((data >> 16) & 0xFF) << 8) | (((data >> 24) & 0xFF) << 0); |
|||
} |
|||
return res; |
|||
} |
|||
|
|||
quint16 CommonUtil::Lc_ntohs(quint16 data) |
|||
{ |
|||
quint16 res = 0; |
|||
if(data == 0 || isBigEndianOrder()){ |
|||
res = data; |
|||
}else{ |
|||
res = (((data >> 0) & 0xFF) << 8) | (((data >> 8) & 0xFF) << 0) ; |
|||
} |
|||
return res; |
|||
} |
|||
|
|||
quint16 CommonUtil::Lc_htons(quint16 data) |
|||
{ |
|||
quint16 res = 0; |
|||
if(data == 0 || isBigEndianOrder()){ |
|||
res = data; |
|||
}else{ |
|||
res = (((data >> 0) & 0xFF) << 8) | (((data >> 8) & 0xFF) << 0) ; |
|||
} |
|||
return res; |
|||
} |
|||
#endif |
|||
|
|||
void CommonUtil::Lc_buf_copy_uc(quint8 *d,const quint8 *s,quint32 num) |
|||
{ |
|||
quint32 i; |
|||
for(i = 0; i < num; i ++) |
|||
{ |
|||
*(d+i) = *(s+i); |
|||
} |
|||
} |
|||
|
|||
void CommonUtil::delay(quint32 n) |
|||
{ |
|||
while(n--); |
|||
} |
|||
|
|||
QString CommonUtil::getHostIpAddress() |
|||
{ |
|||
QString strIpAddress; |
|||
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); |
|||
// 获取第一个本主机的IPv4地址
|
|||
int nListSize = ipAddressesList.size(); |
|||
for (int i = 0; i < nListSize; ++i) |
|||
{ |
|||
if (ipAddressesList.at(i) != QHostAddress::LocalHost && |
|||
ipAddressesList.at(i).toIPv4Address()) { |
|||
strIpAddress = ipAddressesList.at(i).toString(); |
|||
break; |
|||
} |
|||
} |
|||
// 如果没有找到,则以本地IP地址为IP
|
|||
if (strIpAddress.isEmpty()) |
|||
strIpAddress = QHostAddress(QHostAddress::LocalHost).toString(); |
|||
return strIpAddress; |
|||
} |
|||
|
|||
QString CommonUtil::getHostMacAddress() |
|||
{ |
|||
QList<QNetworkInterface> nets = QNetworkInterface::allInterfaces();// 获取所有网络接口列表
|
|||
int nCnt = nets.count(); |
|||
QString strMacAddr = ""; |
|||
for(int i = 0; i < nCnt; i ++) |
|||
{ |
|||
// 如果此网络接口被激活并且正在运行并且不是回环地址,则就是我们需要找的Mac地址
|
|||
if(nets[i].flags().testFlag(QNetworkInterface::IsUp) && nets[i].flags().testFlag(QNetworkInterface::IsRunning) && !nets[i].flags().testFlag(QNetworkInterface::IsLoopBack)) |
|||
{ |
|||
strMacAddr = nets[i].hardwareAddress(); |
|||
break; |
|||
} |
|||
} |
|||
return strMacAddr; |
|||
} |
@ -0,0 +1,30 @@ |
|||
#ifndef COMMONUTIL_H |
|||
#define COMMONUTIL_H |
|||
|
|||
#include <QByteArray> |
|||
|
|||
class CommonUtil |
|||
{ |
|||
public: |
|||
CommonUtil(); |
|||
static QByteArray quint8ArrToQByteArray(quint8 *arr,int lengths); |
|||
static void crc16(quint8 crc[], quint8 data[], int pos,int len); |
|||
static int isBigEndianOrder(); |
|||
#ifdef Q_OS_WIN |
|||
static quint32 Lc_ntohl(quint32 data); |
|||
static quint32 Lc_htonl(quint32 data); |
|||
static quint16 Lc_ntohs(quint16 data); |
|||
static quint16 Lc_htons(quint16 data); |
|||
#endif |
|||
static void Lc_buf_copy_uc(quint8 *d,const quint8 *s,quint32 num); |
|||
static void delay(quint32 n); |
|||
static QString getHostIpAddress(); |
|||
static QString getHostMacAddress(); |
|||
static QString ByteArrayToHexString(const QByteArray &ba); |
|||
static QByteArray HexStringToByteArray(QString HexString); |
|||
|
|||
static QString ByteArrayToNonZeroString(const QByteArray &ba); |
|||
static QString i_pA_2_text(unsigned int iPA); |
|||
}; |
|||
|
|||
#endif // COMMONUTIL_H
|