LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1193|回复: 14

QT初学者关于Qt Designer Manual中第一个例子的问题

[复制链接]
发表于 2004-8-25 10:50:39 | 显示全部楼层 |阅读模式
我编译的时候有以下错误,不知道是怎么回事?
它让加的两个头文件<qclipboard.h>和<qapplication.h>我都加了呀 还能是什么原因呢,请达人指教了。。。。
In file included from .ui/multiclipform.cpp:27:
../111/multiclipform.ui.h: In member function `virtual void
multiclipForm::init()':
../111/multiclipform.ui.h:14: `lengthLCDNumber' undeclared (first use this
function)
../111/multiclipform.ui.h:14: (Each undeclared identifier is reported only once
for each function it appears in.)
../111/multiclipform.ui.h:15: `currentLineEdit' undeclared (first use this
function)
In file included from .ui/multiclipform.cpp:27:
../111/multiclipform.ui.h: In member function `virtual void
multiclipForm::dataChanged()':
../111/multiclipform.ui.h:31: `autoCheckBox' undeclared (first use this
function)
In file included from .ui/multiclipform.cpp:27:
../111/multiclipform.ui.h: In member function `virtual void
multiclipForm::copyPrevious()':
../111/multiclipform.ui.h:53: `clippingsListBox' undeclared (first use this
function)
/usr/lib/qt3-gcc3.2/include/qstringlist.h: At top level:
.ui/multiclipform.cpp:29: warning: `QPixmap uic_load_pixmap_multiclipForm(const
QString&)' defined but not used
make: *** [.obj/multiclipform.o] Error 1
 楼主| 发表于 2004-8-25 11:21:27 | 显示全部楼层
怎么没人理呢,是我问的不过具体让大家无从解答?
发表于 2004-8-25 12:50:12 | 显示全部楼层
../111/multiclipform.ui.h:14: `lengthLCDNumber' undeclared (first use this
function)
看看这里。最好吧这个文件内容贴出来
 楼主| 发表于 2004-8-26 07:33:59 | 显示全部楼层
这是我的源程序[php]

#include <qclipboard.h>
#include <qapplication.h>
QClipboard *cb
void multiclipForm::init()
{
        lengthLCDNumber->setBackgroundColor( darkBlue );
        currentLineEdit->setFocus();

        cb = qApp->clipboard();
        connect( cb, SIGNAL( dataChanged() ), SLOT( dataChanged() ) );
        if ( cb->supportsSelection() )
            connect( cb, SIGNAL( selectionChanged() ), SLOT( selectionChanged() ) );

        dataChanged();
}


void multiclipForm::dataChanged()
{
        QString text;
        text = cb->text();
        clippingChanged( text );
        if ( autoCheckBox->isChecked() )
            addClipping();
}


void multiclipForm::selectionChanged()
{
        cb->setSelectionMode( TRUE );
        dataChanged();
        cb->setSelectionMode( FALSE );
}



void multiclipForm::clippingChanged( const QString & clipping )
{
        currentLineEdit->setText( clipping );
        lengthLCDNumber->display( (int)clipping.length() );
}

void multiclipForm::addClipping()
{
        QString text = currentLineEdit->text();
        if ( ! text.isEmpty() ) {
            lengthLCDNumber->display( (int)text.length() );
            int i = 0;
            for ( ; i < (int)clippingsListBox->count(); i++ ) {
                if ( clippingsListBox->text( i ) == text ) {
                    i = -1; // Do not add duplicates
                    break;
                }
            }
            if ( i != -1 )
                clippingsListBox->insertItem( text, 0 );
        }
}


void multiclipForm::copyPrevious()
{
        if ( clippingsListBox->currentItem() != -1 ) {
            cb->setText( clippingsListBox->currentText() );
            if ( cb->supportsSelection() ) {
                cb->setSelectionMode( TRUE );
                cb->setText( clippingsListBox->currentText() );
                cb->setSelectionMode( FALSE );
            }
        }
}

void multiclipForm::deleteClipping()
{
        clippingChanged( "" );
        clippingsListBox->removeItem( clippingsListBox->currentItem() );
}

[/php]
 楼主| 发表于 2004-8-26 07:37:14 | 显示全部楼层
我感觉程序本身应该是没问题,可能是我QT不太会用造成的。
我觉得我是照Manual一步步做的,可我的英文比较烂难免可能有纰漏。望顺便指教一下QT应用的基本流程。不胜感激。。
发表于 2004-8-26 09:22:56 | 显示全部楼层
你这个是后最名为.h得那个文件吗???
这个应该是用 uic 产生得.cpp得文件,如果是.h那就肯定错了
用man uic看看uic得帮助。
发表于 2004-8-26 09:27:32 | 显示全部楼层
从*.ui文件得到*.h和*.cpp文件可以使用下面得命令
uic -o form1.h form1.ui
uic -o form1.cpp -impl form1.h form1.ui
 楼主| 发表于 2004-8-26 10:54:49 | 显示全部楼层
.
 楼主| 发表于 2004-8-26 10:57:01 | 显示全部楼层
我贴的的确是.h
从ui或h到.cpp不是靠gmake -o Makefile .pro中就自动生成的吗?
我糊涂了。
我编完程序后就直接#gmake -o Makefile .pro
#make
不是这么个顺序吗?
发表于 2004-8-26 13:32:05 | 显示全部楼层
QT Designer好像是可以这样生成pro文件。
Manual上这两个头文件应该加在哪个文件里面?
还有,QT路径有没有加到ld.conf里面?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表