• 9120阅读
  • 6回复

有关Ui的设置问题。 [复制链接]

上一主题 下一主题
离线shifan
 
只看楼主 倒序阅读 楼主  发表于: 2009-11-15
/////////////////////////////////////////////////////getItem.h
#ifndef GETITEM_H
#define GETITEM_H
#include<QDialog>
#include"ui_getItem.h"
#include<QtUiTools>

namespace Ui
{
    class getItem;
}
class getItem:public QDialog
{
    Q_OBJECT
public:
    getItem();
    ~getItem();
private slots:
    void finish();
private:
    Ui::getItem *getGetItem;
};

#endif // GETITEM_H

/////////////////////////////////////////getItem.cpp
#include "getItem.h"
//#include "ui_getItem.h"
#include<QDate>
getItem::getItem()
        :QDialog(),getGetItem(new Ui::getItem)
{
    this->setModal(true);
    getGetItem->setupUi(this);
    (getGetItem->getDateEdit)->setDate(QDate::currentDate());

    connect(getGetItem->buttonBox,SIGNAL(accepted()),this,SLOT(finish()));
    connect(getGetItem->buttonBox,SIGNAL(rejected()),this,SLOT(finish()));
}
getItem::~getItem()
{
   // delete getGetItem;
}
void getItem::finish()
{

}

然后还有一个叫getItem.ui的文件。mian 函数什么的都是测试无误的。

但是报错:
Running build steps for project financeQt...
Starting: /home/shifan/public/qt/qt/bin/qmake /home/shifan/document/cpp/financeQt/financeQt/financeQt.pro -spec linux-g++ -r CONFIG+=debug
Exited with code 0.
Starting: /usr/bin/make -w
make: Entering directory `/home/shifan/document/cpp/financeQt/financeQt'
g++ -c -pipe -g -D_REENTRANT -Wall -W -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../public/qt/qt/mkspecs/linux-g++ -I. -I../../../../public/qt/qt/include/QtUiTools -I../../../../public/qt/qt/include/QtCore -I../../../../public/qt/qt/include/QtGui -I../../../../public/qt/qt/include/QtXml -I../../../../public/qt/qt/include/QtSql -I../../../../public/qt/qt/include -I. -I. -o getItem.o getItem.cpp
make: Leaving directory `/home/shifan/document/cpp/financeQt/financeQt'
getItem.cpp: In constructor ‘getItem::getItem()’:
getItem.cpp:5: 错误:invalid use of incomplete type ‘struct Ui::getItem’
getItem.h:9: 错误:forward declaration of ‘struct Ui::getItem’
getItem.cpp:8: 错误:invalid use of incomplete type ‘struct Ui::getItem’
getItem.h:9: 错误:forward declaration of ‘struct Ui::getItem’
getItem.cpp:9: 错误:invalid use of incomplete type ‘struct Ui::getItem’
getItem.h:9: 错误:forward declaration of ‘struct Ui::getItem’
getItem.cpp:11: 错误:invalid use of incomplete type ‘struct Ui::getItem’
getItem.h:9: 错误:forward declaration of ‘struct Ui::getItem’
getItem.cpp:12: 错误:invalid use of incomplete type ‘struct Ui::getItem’
getItem.h:9: 错误:forward declaration of ‘struct Ui::getItem’
make: *** [getItem.o] 错误 1
Exited with code 2.
Error while building project financeQt
When executing build step 'Make'

不知道是什么原因,困扰了我一晚上。
离线foxyz

只看该作者 1楼 发表于: 2009-11-16
请问楼主,为什么更改了qtcreator自动生成的代码?
把cpp里边的//#include "ui_getItem.h"注释掉了,而在header file里边又加上了这个。析构函数里边不delete
离线shifan
只看该作者 2楼 发表于: 2009-11-16
这不是qtcreator自动生成的代码,是我一个字母一个字母的敲进去的。为了弄清楚到底怎样才是对的,我做了一些改动然后实验,这样重复了很多次。现在看到的版本仅仅是在实验过程中逐渐发展出来的。
离线dbzhang800

只看该作者 3楼 发表于: 2009-11-16
不是自动生成的? 看来你需要检查你的ui文件,或者贴出来看看
离线shifan
只看该作者 4楼 发表于: 2009-11-16
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>597</width>
    <height>477</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Dialog</string>
  </property>
  <widget class="QDialogButtonBox" name="buttonBox">
   <property name="geometry">
    <rect>
     <x>220</x>
     <y>360</y>
     <width>341</width>
     <height>32</height>
    </rect>
   </property>
   <property name="orientation">
    <enum>Qt::Horizontal</enum>
   </property>
   <property name="standardButtons">
    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
   </property>
  </widget>
  <widget class="QWidget" name="layoutWidget">
   <property name="geometry">
    <rect>
     <x>10</x>
     <y>20</y>
     <width>320</width>
     <height>333</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QLabel" name="label">
        <property name="text">
         <string>发生日期</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QDateEdit" name="getDateEdit">
        <property name="dateTime">
         <datetime>
          <hour>0</hour>
          <minute>0</minute>
          <second>0</second>
          <year>2009</year>
          <month>11</month>
          <day>15</day>
         </datetime>
        </property>
        <property name="maximumDate">
         <date>
          <year>2100</year>
          <month>12</month>
          <day>31</day>
         </date>
        </property>
        <property name="minimumDate">
         <date>
          <year>2000</year>
          <month>6</month>
          <day>1</day>
         </date>
        </property>
        <property name="minimumTime">
         <time>
          <hour>0</hour>
          <minute>0</minute>
          <second>0</second>
         </time>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <widget class="QLabel" name="label_2">
        <property name="text">
         <string>费用项目</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QComboBox" name="getFeeItemCombo"/>
      </item>
      <item>
       <widget class="QPushButton" name="pushButton">
        <property name="text">
         <string>...</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_3">
      <item>
       <widget class="QLabel" name="label_3">
        <property name="text">
         <string>费用明细</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QComboBox" name="getFeeSpecialCombo"/>
      </item>
      <item>
       <widget class="QPushButton" name="pushButton_2">
        <property name="text">
         <string>...</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_4">
      <item>
       <widget class="QLabel" name="label_4">
        <property name="text">
         <string>收支人</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QComboBox" name="getFeeManCombo"/>
      </item>
      <item>
       <widget class="QPushButton" name="pushButton_3">
        <property name="text">
         <string>...</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_5">
      <item>
       <widget class="QLabel" name="label_5">
        <property name="text">
         <string>备注</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QTextEdit" name="getBlockBox"/>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
  <widget class="QWidget" name="layoutWidget">
   <property name="geometry">
    <rect>
     <x>340</x>
     <y>20</y>
     <width>236</width>
     <height>331</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_11">
      <item>
       <widget class="QLabel" name="label_6">
        <property name="text">
         <string>费用类型</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QComboBox" name="getType">
        <item>
         <property name="text">
          <string>收入</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>支出</string>
         </property>
        </item>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_10">
      <item>
       <widget class="QLabel" name="label_7">
        <property name="text">
         <string>收入金额</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="getIncomeLine">
        <property name="text">
         <string>0</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLabel" name="label_11">
        <property name="text">
         <string>元</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_9">
      <item>
       <widget class="QLabel" name="label_8">
        <property name="text">
         <string>支出金额</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="getOutputLine">
        <property name="text">
         <string>0</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLabel" name="label_12">
        <property name="text">
         <string>元</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_8">
      <item>
       <widget class="QLabel" name="label_9">
        <property name="text">
         <string>净受金额</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="getTotalLine">
        <property name="text">
         <string>0</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLabel" name="label_13">
        <property name="text">
         <string>元</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_7">
      <item>
       <widget class="QLabel" name="label_10">
        <property name="text">
         <string>记账人</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="getRecorderLine"/>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_6">
      <item>
       <widget class="QLabel" name="label_14">
        <property name="text">
         <string>记账时间</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QDateTimeEdit" name="getTimeEdit">
        <property name="dateTime">
         <datetime>
          <hour>0</hour>
          <minute>0</minute>
          <second>0</second>
          <year>2009</year>
          <month>11</month>
          <day>15</day>
         </datetime>
        </property>
        <property name="maximumDate">
         <date>
          <year>2100</year>
          <month>12</month>
          <day>31</day>
         </date>
        </property>
        <property name="minimumDate">
         <date>
          <year>2000</year>
          <month>6</month>
          <day>1</day>
         </date>
        </property>
       </widget>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
</widget>
<resources/>
<connections>
  <connection>
   <sender>buttonBox</sender>
   <signal>accepted()</signal>
   <receiver>Dialog</receiver>
   <slot>show()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>248</x>
     <y>254</y>
    </hint>
    <hint type="destinationlabel">
     <x>157</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>buttonBox</sender>
   <signal>rejected()</signal>
   <receiver>Dialog</receiver>
   <slot>reject()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>316</x>
     <y>260</y>
    </hint>
    <hint type="destinationlabel">
     <x>286</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
</connections>
</ui>
离线shifan
只看该作者 5楼 发表于: 2009-11-16
,感谢dbzhang80,我明白了,ui的class名字应该是Dialog而不是getItem,我是听你说要把ui文件贴出来才想到看看ui文件里面的类到底是什么样的,终于搞清楚了,十分感谢~
离线wd007

只看该作者 6楼 发表于: 2009-11-16
objectName的值就是对应的Ui::xxx中的xxx
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
快速回复
限100 字节
 
上一个 下一个