说明:本文参考至csdn上的一篇博客,很抱歉的是忘了链接地址了!
刚学Qt,想做点简单的东西,于是参考别人的代码写了个Qt版简易计算器。
开发环境:
|- Linux环境,redhat Enterprise5.4
|- Qt4.2
代码如下:
calculator.ui
<ui version="4.0" >
<class>calForm</class>
<widget class="QWidget" name="calForm" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>404</height>
</rect>
</property>
<property name="windowTitle" >
<string>计算器</string>
</property>
<property name="windowIcon" >
<iconset>image/calculator.PNG</iconset>
</property>
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<widget class="QPushButton" name="_6Btn" >
<property name="geometry" >
<rect>
<x>5</x>
<y>252</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>6</string>
</property>
</widget>
<widget class="QPushButton" name="_4Btn" >
<property name="geometry" >
<rect>
<x>142</x>
<y>252</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>4</string>
</property>
</widget>
<widget class="QPushButton" name="_3Btn" >
<property name="geometry" >
<rect>
<x>5</x>
<y>303</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>3</string>
</property>
</widget>
<widget class="QPushButton" name="_2Btn" >
<property name="geometry" >
<rect>
<x>72</x>
<y>303</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>2</string>
</property>
</widget>
<widget class="QPushButton" name="_1Btn" >
<property name="geometry" >
<rect>
<x>142</x>
<y>303</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>1</string>
</property>
</widget>
<widget class="QPushButton" name="_0Btn" >
<property name="geometry" >
<rect>
<x>5</x>
<y>359</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>0</string>
</property>
</widget>
<widget class="QPushButton" name="dotBtn" >
<property name="geometry" >
<rect>
<x>72</x>
<y>359</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>.</string>
</property>
</widget>
<widget class="QPushButton" name="_8Btn" >
<property name="geometry" >
<rect>
<x>72</x>
<y>201</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>8</string>
</property>
</widget>
<widget class="QPushButton" name="_5Btn" >
<property name="geometry" >
<rect>
<x>72</x>
<y>252</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>5</string>
</property>
</widget>
<widget class="QPushButton" name="_9Btn" >
<property name="geometry" >
<rect>
<x>5</x>
<y>201</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>9</string>
</property>
</widget>
<widget class="QPushButton" name="_7Btn" >
<property name="geometry" >
<rect>
<x>142</x>
<y>201</y>
<width>51</width>
<height>27</height>
</rect>
</property>
<property name="text" >
<string>7</string>
</property>
</widget>
<widget clas