• 4410阅读
  • 0回复

NO such slot :listVIEW::currentChangSlot [复制链接]

上一主题 下一主题
离线luodan_000
 
只看楼主 倒序阅读 楼主  发表于: 2008-03-14
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
NO such slot :listVIEW::currentChangSlot
object sender : listView
object receiver: listview

源代码如下
#ifndef LISTVIEW_H
#define LISTVIEW_H

#include <qvariant.h>
#include <qpixmap.h>
#include <qwidget.h>
#include <qlistview.h>
#include <qlineedit.h>



class listView : public QListView
{
   
    Q_OBJECT   

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

    QLineEdit* listViewEdit;
   
   

protected:

public slots:
    void currentChangeSlot(QListViewItem* item);
    virtual void languageChange();
   

private:
    QPixmap image0;
    int current;

};

#endif

#include <listview.h>

#include <qvariant.h>
#include <qlineedit.h>
#include <qheader.h>
#include <qlistview.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>

static const unsigned char image0_data[] = {
    0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
    0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x12,
    0x08, 0x06, 0x00, 0x00, 0x00, 0x56, 0xce, 0x8e, 0x57, 0x00, 0x00, 0x04,
    0x64, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x3d, 0x91, 0xdd, 0x6f, 0x14,
    0x55, 0x00, 0xc5, 0xcf, 0x9d, 0x3b, 0xb3, 0xdd, 0xd9, 0x99, 0xfd, 0xde,
    0xb5, 0xed, 0x76, 0xdb, 0xd2, 0x4a, 0xdb, 0x6d, 0x0b, 0x42, 0x91, 0x16,
    0x42, 0xab, 0xb1, 0x86, 0x62, 0x52, 0x34, 0x21, 0xbc, 0x6a, 0x8c, 0x86,
    0xc8, 0x83, 0xf1, 0x89, 0x07, 0xd4, 0x17, 0x13, 0xff, 0x07, 0x79, 0xe3,
    0x1f, 0xb0, 0x89, 0xd1, 0x90, 0x20, 0x26, 0x2a, 0x8d, 0x3c, 0x88, 0x12,
    0x29, 0x48, 0xb1, 0x9f, 0x2c, 0xa5, 0xf4, 0x73, 0xbb, 0xdb, 0xee, 0xcc,
    0xce, 0xee, 0xcc, 0xce, 0xc7, 0xbd, 0xd7, 0x07, 0xc4, 0x5f, 0x72, 0xde,
    0x4e, 0x7e, 0x0f, 0xe7, 0x10, 0x21, 0x04, 0x86, 0x86, 0x87, 0xe4, 0x1d,
    0xb3, 0x32, 0x24, 0x14, 0x69, 0x0a, 0x4c, 0xac, 0xb5, 0x78, 0x64, 0xf6,
    0xf3, 0xab, 0x57, 0x8d, 0x2b, 0x57, 0xae, 0x08, 0x00, 0xb8, 0xf0, 0xde,
    0xbb, 0xca, 0xc6, 0x5a, 0xb1, 0xa5, 0x77, 0x60, 0xb0, 0xf9, 0xe1, 0x47,
    0x1f, 0x07, 0xd7, 0xaf, 0x5f, 0xa7, 0xdb, 0xdb, 0xdb, 0x92, 0xaa, 0xaa,
    0x62, 0x7a, 0x7a, 0x9a, 0x5d, 0xba, 0x74, 0x49, 0xd0, 0x72, 0x75, 0x9f,
    0x2c, 0x3d, 0x59, 0xcd, 0x44, 0x5e, 0x49, 0x8c, 0xc7, 0xfa, 0x72, 0x27,
    0x58, 0x58, 0x0e, 0x9b, 0x95, 0x83, 0x83, 0xe5, 0x85, 0x45, 0x73, 0xbf,
    0x5c, 0x09, 0x2e, 0x5f, 0xbe, 0x1c, 0xaa, 0x6d, 0xaf, 0x8f, 0x71, 0xc7,
    0xba, 0xf0, 0xf0, 0x9f, 0x05, 0xe7, 0xe7, 0xdb, 0xb3, 0xce, 0xfa, 0xf2,
    0xf2, 0x90, 0x53, 0x2a, 0x8d, 0x95, 0x36, 0x37, 0xbb, 0xfe, 0xb8, 0x77,
    0xcf, 0xda, 0xda, 0xdd, 0xb5, 0xa9, 0x61, 0x5b, 0x31, 0xa1, 0x85, 0xc6,
    0xdb, 0x87, 0x7a, 0xcf, 0xea, 0xfd, 0x1d, 0xc9, 0x3d, 0xbf, 0x1e, 0x6b,
    0xd4, 0xeb, 0xba, 0x6d, 0xd4, 0xcc, 0x47, 0x7f, 0x3d, 0xf0, 0x43, 0xdc,
    0x9d, 0x38, 0x9e, 0x8f, 0x7f, 0x95, 0x51, 0xfc, 0xf7, 0xcb, 0x46, 0x4d,
    0xaf, 0x5a, 0xb6, 0xd5, 0x1a, 0x56, 0x3f, 0x2d, 0x28, 0xca, 0x17, 0xac,
    0xd9, 0x3c, 0x67, 0xb8, 0xee, 0xc2, 0x7e, 0xbd, 0xbe, 0x46, 0x65, 0x2d,
    0xdc, 0x25, 0xa7, 0xf5, 0xe9, 0x68, 0x5f, 0x2e, 0x6f, 0xc5, 0x24, 0xec,
    0xd9, 0x35, 0xd9, 0x6b, 0x34, 0x53, 0xbc, 0x6a, 0x2b, 0x19, 0x22, 0x0d,
    0x8c, 0xf6, 0xb6, 0x7d, 0x36, 0xd1, 0x1e, 0x9a, 0x48, 0xb2, 0x03, 0x89,
    0x22, 0xd0, 0x2c, 0x8f, 0x77, 0xe6, 0xd4, 0xd8, 0xf1, 0x29, 0x4d, 0x6f,
    0xad, 0x35, 0x1a, 0xd1, 0x1d, 0xc6, 0xee, 0x36, 0x09, 0x59, 0x94, 0x21,
    0xd0, 0x74, 0x0c, 0xab, 0x6e, 0x94, 0x2a, 0x10, 0x7a, 0x1a, 0x22, 0x60,
    0x40, 0xd3, 0x8f, 0xa6, 0x64, 0x65, 0x72, 0xac, 0xb3, 0xb5, 0xe7, 0x74,
    0xae, 0x65, 0xb0, 0x51, 0x2a, 0xa2, 0xee, 0x38, 0xf4, 0x44, 0x5b, 0xe4,
    0xb0, 0xcf, 0x1a, 0xf9, 0x9a, 0xd3, 0x94, 0x0d, 0x97, 0xc0, 0xe1, 0x1c,
    0x81, 0x10, 0xba, 0xf0, 0x3c, 0x55, 0x56, 0x40, 0x1a, 0x82, 0x81, 0x65,
    0x92, 0x49, 0x20, 0x9e, 0x44, 0x49, 0x29, 0x29, 0x9a, 0xa4, 0xb4, 0x4d,
    0x74, 0xc7, 0xba, 0x4e, 0x66, 0x68, 0xa6, 0xba, 0xf3, 0x4c, 0x79, 0x5c,
    0x25, 0xb0, 0x4c, 0x86, 0xb7, 0xf2, 0x81, 0x74, 0x2c, 0x4d, 0x22, 0x4f,
    0x8d, 0x26, 0xd6, 0x6a, 0x0c, 0x3b, 0x9c, 0xc1, 0x05, 0x14, 0xca, 0x18,
    0x95, 0x03, 0xc1, 0x25, 0x11, 0x22, 0xaa, 0xd5, 0x22, 0xc0, 0x2c, 0x53,
    0x89, 0xd5, 0xdc, 0xb6, 0xe3, 0xd9, 0x64, 0xef, 0xe9, 0x90, 0x9f, 0x32,
    0x4a, 0x5b, 0xf2, 0xb2, 0x1d, 0x42, 0xe7, 0xc9, 0xd7, 0xe1, 0x35, 0x2c,
    0x6c, 0xec, 0x16, 0x91, 0x72, 0xb7, 0xd0, 0x9f, 0x60, 0xf8, 0xdb, 0x77,
    0x71, 0x40, 0x05, 0x7c, 0x2e, 0x29, 0x92, 0x10, 0x94, 0xb6, 0x77, 0xe4,
    0x60, 0xda, 0xf5, 0x88, 0xe7, 0x7b, 0x5d, 0x8a, 0x61, 0xf7, 0x1e, 0xf3,
    0xc4, 0xe1, 0x53, 0x21, 0x2f, 0x65, 0xee, 0x6e, 0xca, 0x2b, 0xcd, 0x30,
    0xba, 0x47, 0x46, 0x71, 0x7e, 0xfa, 0x0d, 0x9c, 0x1a, 0x3b, 0x06, 0x45,
    0x4f, 0x60, 0x6b, 0xbb, 0x84, 0x88, 0x67, 0x20, 0xa5, 0x02, 0x1e, 0x08,
    0xaa, 0x2e, 0x32, 0x3e, 0x27, 0x77, 0x68, 0x34, 0xa2, 0x87, 0xac, 0x4a,
    0xb5, 0x10, 0x63, 0xe4, 0xd4, 0x88, 0xa6, 0x9e, 0x38, 0x1d, 0x76, 0xd3,
    0xd6, 0xee, 0x06, 0x5d, 0x72, 0x5a, 0xd0, 0x3d, 0x32, 0x8a, 0xa9, 0xb3,
    0xe3, 0x38, 0x3a, 0xd4, 0x8b, 0x7c, 0x2e, 0x8b, 0xf6, 0x5c, 0x2b, 0x0e,
    0x5c, 0x82, 0xf9, 0xd5, 0x4d, 0xa4, 0x48, 0x13, 0xc3, 0x49, 0x09, 0x4e,
    0xc0, 0xd3, 0x25, 0x5b, 0x54, 0xa8, 0x9a, 0x88, 0xe6, 0x93, 0xed, 0xe9,
    0x4f, 0x06, 0x3a, 0x53, 0xa3, 0x1d, 0xfb, 0xc5, 0x76, 0x6b, 0x7f, 0x87,
    0x3e, 0xa7, 0x69, 0x14, 0xce, 0x4c, 0xe0, 0x9d, 0xa9, 0x33, 0x38, 0x32,
    0x78, 0x08, 0x7a, 0x24, 0x0c, 0x21, 0x04, 0x34, 0x4d, 0x45, 0x5f, 0x7f,
    0x0f, 0x68, 0x2c, 0x8d, 0xc5, 0x67, 0x65, 0xd4, 0x4c, 0x13, 0x21, 0x89,
    0x07, 0x45, 0x53, 0xc4, 0xa9, 0x9a, 0x8c, 0x9e, 0xcc, 0x16, 0x0e, 0x8d,
    0x7b, 0x1d, 0x59, 0xff, 0x97, 0x95, 0x3d, 0xba, 0xc7, 0x12, 0xea, 0xe4,
    0xd9, 0x49, 0xf9, 0xdc, 0xe4, 0x28, 0xfa, 0x5e, 0xcd, 0x23, 0x19, 0xd7,
    0xf1, 0x78, 0xe9, 0x29, 0xbe, 0xbb, 0xf1, 0x1b, 0xd6, 0x9f, 0xef, 0x20,
    0x99, 0x4a, 0xa0, 0x30, 0xd0, 0x83, 0x86, 0x12, 0xc5, 0x8d, 0x47, 0x15,
    0xfc, 0xba, 0x62, 0x3e, 0x6a, 0xf8, 0x98, 0xa1, 0xe1, 0x44, 0xf4, 0xcd,
    0xd4, 0x70, 0xf7, 0x61, 0x79, 0xa0, 0xcd, 0x29, 0x7b, 0x0d, 0xe7, 0x48,
    0xb6, 0x2d, 0xfe, 0xc1, 0xf9, 0xb7, 0xb5, 0xd7, 0x06, 0x7b, 0x10, 0x8b,
    0xaa, 0x08, 0x29, 0x32, 0x7e, 0xff, 0x73, 0x1e, 0x5f, 0x7f, 0xf9, 0x0d,
    0xca, 0xff, 0x3c, 0x43, 0xa2, 0x27, 0x8f, 0x89, 0xb1, 0xa3, 0x68, 0xcb,
    0x26, 0xb0, 0xf4, 0x64, 0x03, 0x6b, 0xcf, 0x77, 0xbf, 0x65, 0x5c, 0x7c,
    0x2f, 0xfb, 0x84, 0xf7, 0x57, 0x84, 0xed, 0x9b, 0x4f, 0x56, 0x15, 0xdb,
    0xac, 0x8b, 0x50, 0x3a, 0x89, 0x78, 0x4c, 0x43, 0x34, 0xaa, 0x81, 0x40,
    0x80, 0x10, 0x02, 0x02, 0x20, 0x0f, 0x8a, 0x11, 0xc8, 0x00, 0x91, 0x20,
    0x51, 0x19, 0x8a, 0xa2, 0x80, 0x52, 0x0a, 0x49, 0x22, 0x36, 0xa5, 0xd4,
    0x94, 0x99, 0xeb, 0xdd, 0xdf, 0xbe, 0xbf, 0x52, 0x0b, 0x14, 0xa9, 0x5d,
    0x58, 0x4d, 0x4a, 0xa3, 0x39, 0x9f, 0xb3, 0x00, 0xb6, 0xed, 0x40, 0x08,
    0x01, 0x00, 0x60, 0x01, 0x07, 0xe1, 0x1c, 0x24, 0xe0, 0x60, 0x41, 0x80,
    0x86, 0xed, 0xc0, 0x69, 0xba, 0x10, 0x9c, 0x83, 0x00, 0x01, 0xa5, 0x34,
    0x90, 0xe3, 0x08, 0xdf, 0x36, 0xd6, 0xcd, 0x05, 0xc8, 0xe8, 0x64, 0x5e,
    0x30, 0x58, 0x8e, 0xef, 0x65, 0x7f, 0xf8, 0xf1, 0x4e, 0x36, 0x1e, 0x8d,
    0x84, 0x38, 0xe7, 0x00, 0x80, 0xd5, 0xe2, 0x26, 0x4a, 0x10, 0x98, 0x73,
    0xea, 0xd8, 0xbc, 0xfb, 0x00, 0xb5, 0x5a, 0x0d, 0xf5, 0x86, 0x8d, 0xe5,
    0xe2, 0x46, 0xcd, 0xf3, 0x02, 0x93, 0x52, 0xd9, 0x23, 0xd7, 0xae, 0x5d,
    0x23, 0x33, 0x33, 0x33, 0xa1, 0x62, 0xb1, 0x18, 0xae, 0x56, 0xab, 0x99,
    0x98, 0x1e, 0x1e, 0x8b, 0xc7, 0xb4, 0xa3, 0x00, 0x12, 0x8c, 0xf1, 0x16,
    0x00, 0xc4, 0x6d, 0x7a, 0xbc, 0xb2, 0xb3, 0x0f, 0x4d, 0x91, 0xd1, 0x92,
    0x8e, 0x41, 0xd7, 0x55, 0x30, 0xc6, 0x45, 0xd5, 0xac, 0x1f, 0xd8, 0xb6,
    0xfb, 0x53, 0x22, 0x99, 0x7c, 0x48, 0x84, 0x10, 0x58, 0x5c, 0x5c, 0xc4,
    0xec, 0xec, 0x2c, 0xb9, 0x79, 0xf3, 0x26, 0x9d, 0x9f, 0x9f, 0x8f, 0x58,
    0x96, 0x15, 0xf5, 0x7d, 0x5f, 0xe3, 0xfc, 0x85, 0x08, 0x80, 0xf8, 0x2f,
    0x2f, 0x21, 0x00, 0x84, 0x24, 0x49, 0xae, 0xa6, 0x69, 0xd5, 0xe1, 0xe1,
    0xe1, 0x1a, 0x79, 0xb9, 0xc3, 0x4b, 0x6e, 0xdd, 0xba, 0x45, 0xe6, 0xe6,
    0xe6, 0xa4, 0x62, 0xb1, 0x48, 0x0c, 0xc3, 0x20, 0x41, 0x10, 0x80, 0x10,
    0x02, 0x49, 0x92, 0xfe, 0xef, 0x08, 0xf1, 0xe2, 0x04, 0x5d, 0xd7, 0x45,
    0xa1, 0x50, 0xe0, 0x17, 0x2f, 0x5e, 0xe4, 0xff, 0x02, 0x25, 0x75, 0x33,
    0xc3, 0x49, 0x23, 0xb8, 0x98, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
    0x44, 0xae, 0x42, 0x60, 0x82
};


/*
*  Constructs a listView as a child of 'parent', with the
*  name 'name' and widget flags set to 'f'.
*/
listView::listView( QWidget* parent, const char* name, WFlags fl )
    : QListView( parent, name, fl )
{
    QImage img;
    img.loadFromData( image0_data, sizeof( image0_data ), "PNG" );
    image0 = img;
    if ( !name )
    setName( "listView" );
   

    listViewEdit = new QLineEdit( this, "listViewEdit" );

   
    addColumn( tr( "Port" ) );
    header()->setClickEnabled( FALSE, this->header()->count() - 1 );
    header()->setResizeEnabled( FALSE, this->header()->count() - 1 );
    addColumn( tr( "Name" ) );
    header()->setClickEnabled( FALSE, this->header()->count() - 1 );
    header()->setResizeEnabled( FALSE, this->header()->count() - 1 );
    addColumn( tr( "useless" ) );
    header()->setClickEnabled( FALSE, this->header()->count() - 1 );
    header()->setResizeEnabled( FALSE, this->header()->count() - 1 );

 
    setGeometry( QRect( 0, 0, 370, 350 ) );
    setHScrollBarMode( QListView::AlwaysOff );
    setAllColumnsShowFocus( TRUE );
    setRootIsDecorated( TRUE );
    setColumnWidth ( 0 , 80);
    setColumnWidth ( 1 , 250 );
    setColumnWidth ( 2 , 40 );


    current=startTimer(1000); 
 
    listViewEdit->setGeometry( QRect( 94, firstChild()->itemPos(), 242, 24 ) );
    listViewEdit->hide(); 
   
    languageChange();
   
   
    connect(this,SIGNAL(currentChanged(QListViewItem *)),this,SLOT(currentChangeSlot(QListViewItem *item)));


}

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

/*
*  Sets the strings of the subwidgets using the current
*  language.
*/
void listView::languageChange()
{
    setCaption( tr( "listView" ) );
    header()->setLabel( 0, tr( "Port" ) );
    header()->setLabel( 1, tr( "Name" ) );
    header()->setLabel( 2, tr( "" ) );
    clear();
    QListViewItem * item = new QListViewItem( this, 0 );
    item->setText( 0, tr( "[01]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[02]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[03]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[04]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[05]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[06]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[07]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[08]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[09]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[10]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[11]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[12]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[13]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[14]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[15]" ) );
    item->setPixmap( 0, image0 );

    item = new QListViewItem( this, item );
    item->setText( 0, tr( "[16]" ) );
    item->setPixmap( 0, image0 );

}


void listView::currentChangeSlot(QListViewItem *item)
{
    killTimer(current);
    current=startTimer(1000);
    listViewEdit->setGeometry( QRect( 94, item->itemPos(), 242, 24 ) );
    listViewEdit->hide();
   
}

快速回复
限100 字节
 
上一个 下一个