Linux下Qt版简易计算器

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  刚学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 class=”QPushButton” name=”backBtn” >

  <property name=”geometry” >

  <rect>

  <x>209</x>

  <y>108</y>

  <width>61</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string><-</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”negBtn” >

  <property name=”geometry” >

  <rect>

  <x>142</x>

  <y>359</y>

  <width>51</width>

  <height>27</height>

  </rect>

  </property>

  <property name=”text” >

  <string>-/+</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”plusBtn” >

  <property name=”geometry” >

  <rect>

  <x>210</x>

  <y>151</y>

  <width>61</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>+</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”sqrtBtn” >

  <property name=”geometry” >

  <rect>

  <x>140</x>

  <y>151</y>

  <width>51</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>Sqrt</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”modBtn” >

  <property name=”geometry” >

  <rect>

  <x>70</x>

  <y>151</y>

  <width>51</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>Mod</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”calBtn” >

  <property name=”geometry” >

  <rect>

  <x>142</x>

  <y>108</y>

  <width>51</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>C</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”minusBtn” >

  <property name=”geometry” >

  <rect>

  <x>211</x>

  <y>201</y>

  <width>61</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>-</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”multiBtn” >

  <property name=”geometry” >

  <rect>

  <x>211</x>

  <y>248</y>

  <width>61</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>*</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”divideBtn” >

  <property name=”geometry” >

  <rect>

  <x>211</x>

  <y>299</y>

  <width>61</width>

  <height>31</height>

  </rect>

  </property>

  <property name=”text” >

  <string>/</string>

  </property>

  </widget>

  <widget class=”QPushButton” name=”equlBtn” >

  <property name=”geometry” >

  <rect>

[1][2][3][4]

我要扼住命运的咽喉。

Linux下Qt版简易计算器

相关文章:

你感兴趣的文章:

标签云: