• 5906阅读
  • 1回复

使用uic的问题 [复制链接]

上一主题 下一主题
离线睡眠抱
 
只看楼主 正序阅读 楼主  发表于: 2007-07-13
— 本帖被 XChinux 执行加亮操作(2007-08-12) —
我用Qt  Designer生成gotocelldialog.ui,然后用uic 生成了 gotocelldialog.h和gotocelldialog.cpp,用progen生成gotocelldialog.pro,用tmake生成Makefile。但生成的gotocelldialog.h和gotocelldialog.cpp是空的(在windows下可以看得到,这是为什么呀)。
gotocelldialog.h的内容如下:
/****************************************************************************
** Form interface generated from reading ui file 'gotocelldialog.ui'
**
** Created: 浜? 7鏈?13 19:10:43 2007
**      by: The User Interface Compiler ($Id: qt/main.cpp  3.1.1  edited Nov 21 17:40 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H

#include <qvariant.h>
#include <qdialog.h>

class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class QPushButton;
class QTextEdit;

class GoToCellDialog : public QDialog
{
    Q_OBJECT

public:
    GoToCellDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
    ~GoToCellDialog();

    QLabel* label;
    QTextEdit* lineEdit;
    QPushButton* okButton;
    QPushButton* cancelButton;

protected:
    QVBoxLayout* GoToCellDialogLayout;
    QHBoxLayout* layout1;
    QHBoxLayout* layout2;

protected slots:
    virtual void languageChange();
private slots:
    virtual void enableOkButton();

};

#endif // GOTOCELLDIALOG_H

gotocelldialog.cpp的内容:
/****************************************************************************
** Form implementation generated from reading ui file 'gotocelldialog.ui'
**
** Created: 浜? 7鏈?13 19:10:43 2007
**      by: The User Interface Compiler ($Id: qt/main.cpp  3.1.1  edited Nov 21 17:40 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include "gotocelldialog.h"

#include <qvariant.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qtextedit.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include "gotocelldialog.ui.h"

/*
*  Constructs a GoToCellDialog as a child of 'parent', with the
*  name 'name' and widget flags set to 'f'.
*
*  The dialog will by default be modeless, unless you set 'modal' to
*  TRUE to construct a modal dialog.
*/
GoToCellDialog::GoToCellDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )

{
    if ( !name )
    setName( "GoToCellDialog" );
    GoToCellDialogLayout = new QVBoxLayout( this, 11, 6, "GoToCellDialogLayout");

    layout1 = new QHBoxLayout( 0, 0, 6, "layout1");

    label = new QLabel( this, "label" );
    layout1->addWidget( label );

    lineEdit = new QTextEdit( this, "lineEdit" );
    layout1->addWidget( lineEdit );
    GoToCellDialogLayout->addLayout( layout1 );

    layout2 = new QHBoxLayout( 0, 0, 6, "layout2");
    QSpacerItem* spacer = new QSpacerItem( 71, 31, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout2->addItem( spacer );

    okButton = new QPushButton( this, "okButton" );
    okButton->setEnabled( FALSE );
    okButton->setDefault( TRUE );
    layout2->addWidget( okButton );

    cancelButton = new QPushButton( this, "cancelButton" );
    layout2->addWidget( cancelButton );
    GoToCellDialogLayout->addLayout( layout2 );
    languageChange();
    resize( QSize(290, 187).expandedTo(minimumSizeHint()) );

    // signals and slots connections
    connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
    connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
    connect( lineEdit, SIGNAL( textChanged() ), this, SLOT( enableOkButton() ) );

    // buddies
    label->setBuddy( lineEdit );
}

/*
*  Destroys the object and frees any allocated resources
*/
GoToCellDialog::~GoToCellDialog()
{
    // no need to delete child widgets, Qt does it all for us
}

/*
*  Sets the strings of the subwidgets using the current
*  language.
*/
void GoToCellDialog::languageChange()
{
    setCaption( tr( "Go to Cell" ) );
    label->setText( tr( "&Cell Location" ) );
    okButton->setText( tr( "OK" ) );
    cancelButton->setText( tr( "Cancel" ) );
}
用手写的main.cpp的内容:
#include <qapplication.h>
#include "gotocelldialog.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    GoToCellDialog *dialog = new GoToCellDialog;
    app.setMainWidget(dialog);
    dialog->show();
    return app.exec();
}
运行make是的错误提示:GoToCellDialog和dialog没有定义,也就是窗体的子类没有定义,但在gotocelldialog.h中已经定义了class GoToCellDialog : public QDialog。
请问版主这是什么原因?

离线XChinux

只看该作者 1楼 发表于: 2007-07-14
把全部错误信息帖出来看看
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个