Linux下Qt版简易计算器

本文介绍了一位初学者在Linux Redhat Enterprise5.4系统中使用Qt4.2开发简单计算器的过程,包括代码示例和遇到的问题,如无法添加图标。提供了源代码的下载链接。
摘要由CSDN通过智能技术生成

说明:本文参考至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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值