天嵌 ARM开发社区

 找回密码
 注册
查看: 5554|回复: 23

求助,急!这个错误什么意思?

[复制链接]
冰封雪域 发表于 2012-5-25 14:50:24 | 显示全部楼层 |阅读模式
用Qt designer创建工程,编译时出现error:declaration of' virtual void test::click() '
这是什么意思,click按钮出什么错了?
TQ_guoxixiao 发表于 2012-5-25 15:03:44 | 显示全部楼层
贴出来代码         
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 15:23:39 | 显示全部楼层
/****************************************************************************
** Form interface generated from reading ui file 'test.ui'
**
** Created: Fri May 25 14:45:40 2012
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef TEST_H
#define TEST_H

#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class QPushButton;

class test : public QWidget
{
    Q_OBJECT

public:
    test( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
    ~test();

    QLabel* PixmapLabel1;
    QPushButton* click;

public slots:
    virtual void click();

};

#endif // TEST_H

这个完全是生成的代码,没有改动,只是用qt Creater创建的工程,只有一个按键“Click”
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 15:24:10 | 显示全部楼层
TQ_guoxixiao 发表于 2012-5-25 15:03
贴出来代码

/****************************************************************************
** Form interface generated from reading ui file 'test.ui'
**
** Created: Fri May 25 14:45:40 2012
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef TEST_H
#define TEST_H

#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class QPushButton;

class test : public QWidget
{
    Q_OBJECT

public:
    test( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
    ~test();

    QLabel* PixmapLabel1;
    QPushButton* click;

public slots:
    virtual void click();

};

#endif // TEST_H

这个完全是生成的代码,没有改动,只是用qt Creater创建的工程,只有一个按键“Click”
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 15:27:35 | 显示全部楼层
TQ_guoxixiao 发表于 2012-5-25 15:03
贴出来代码

还有,版主,我把Fedora 10自带的输入法删掉了想安装ibus,但是编译后没有Makefile,所以想恢复自带输入法scim,还能恢复吗?删掉时用的是命令:
su -c 'yum remove scim'
su -c 'yum remove insettings-libs'
回复

使用道具 举报

TQ_guoxixiao 发表于 2012-5-25 16:07:37 | 显示全部楼层
把这个去掉:virtual
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 16:19:20 | 显示全部楼层
TQ_guoxixiao 发表于 2012-5-25 16:07
把这个去掉:virtual

仍然有错误啊,只不过错误变成“declaration of' void test::click() '
回复

使用道具 举报

TQ_guoxixiao 发表于 2012-5-25 16:32:40 | 显示全部楼层
冰封雪域 发表于 2012-5-25 16:19
仍然有错误啊,只不过错误变成“declaration of' void test::click() '

你的cpp文件贴出来
回复

使用道具 举报

TQ-lkp 发表于 2012-5-25 16:46:50 | 显示全部楼层
本帖最后由 TQ-lkp 于 2012-5-25 16:49 编辑

槽定义后,必须在cpp中实现
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 17:05:23 | 显示全部楼层
TQ-lkp 发表于 2012-5-25 16:46
槽定义后,必须在cpp中实现

更改click后,重新生成文件编译后仍然是那个错误,只不过名字由“click”变成我后改的“come_on”
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 17:06:52 | 显示全部楼层
TQ_guoxixiao 发表于 2012-5-25 16:32
你的cpp文件贴出来

/****************************************************************************
** Form implementation generated from reading ui file 'test.ui'
**
** Created: Fri May 25 17:00:32 2012
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "test.h"

#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>


/*
*  Constructs a test which is a child of 'parent', with the
*  name 'name' and widget flags set to 'f'
*/
test::test( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    QPixmap image0( ( const char** ) image0_data );
    if ( !name )
        setName( "test" );
    resize( 584, 480 );
    setCaption( tr( "easytest" ) );
    setIcon( image0 );

    PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
    PixmapLabel1->setGeometry( QRect( 410, 40, 40, 230 ) );
    PixmapLabel1->setPixmap( image0 );
    PixmapLabel1->setScaledContents( TRUE );

    come_on = new QPushButton( this, "come_on" );
    come_on->setGeometry( QRect( 130, 90, 190, 60 ) );
    come_on->setText( tr( "Come On" ) );

    // signals and slots connections
    connect( come_on, SIGNAL( stateChanged(int) ), this, SLOT( come_on() ) );
}

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

void test::come_on()
{
    qWarning( "test::come_on(): Not implemented yet!" );
}

回复

使用道具 举报

TQ_guoxixiao 发表于 2012-5-25 17:09:34 | 显示全部楼层
头文件定义了click信号,对应的cpp文件应该也要有槽函数的实现。
come_on这个名字应该是你定义的槽吧,改成click,即可
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 17:09:47 | 显示全部楼层
这个错误是什么意思呢?
回复

使用道具 举报

 楼主| 冰封雪域 发表于 2012-5-25 17:22:40 | 显示全部楼层
TQ_guoxixiao 发表于 2012-5-25 17:09
头文件定义了click信号,对应的cpp文件应该也要有槽函数的实现。
come_on这个名字应该是你定义的槽吧,改成 ...

原来出错时就是click,这样吧,我把有问题的工程整个传上来版主帮我看一下吧,谢谢啦。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复

使用道具 举报

TQ_guoxixiao 发表于 2012-5-25 17:35:38 | 显示全部楼层
你重新建立工程吧
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2025-6-20 14:49 , Processed in 2.045075 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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