PDA

View Full Version : compile error that i don't understand



incapacitant
29th March 2006, 12:07
I have selected the lines relevant (sic) to the prolem:
first archiv.h puis archiv.cpp



class Archives : public QDialog
{
Q_OBJECT

public:
Archives( QWidget *parent = 0 );
~Archives();

protected:
QAbstractItemModel *model;
QTreeView *qArchiv;

void addArchiv( QString sDate, QString sDest, QString sMsg );
void remplirArchiv();
void selmsg( const QModelIndex() &);

QPushButton *pbOk;
};

//************************************************** **************
connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
this, SLOT( selmsg( const QModelIndex() ) ) );
}

void Archives::selmsg( const QModelIndex() idx )
{
accept();
close();
}

compile:
7 C:\Qt\test\sms\archiv.cpp In file included from archiv.cpp
24 C:\Qt\test\sms\archiv.h variable or field `selmsg' declared void
24 C:\Qt\test\sms\archiv.h expected `;' before '(' token
60 C:\Qt\test\sms\archiv.cpp variable or field `selmsg' declared void
60 C:\Qt\test\sms\archiv.cpp `int Archives::selmsg' is not a static member of `class Archives'
60 C:\Qt\test\sms\archiv.cpp expected primary-expression before "const"

munna
29th March 2006, 12:22
replace


void selmsg( const QModelIndex() &);

by


void selmsg( const QModelIndex &);

and

replace


void Archives::selmsg( const QModelIndex() idx )

by



void Archives::selmsg( const QModelIndex &idx )


and then try to compile again

incapacitant
29th March 2006, 12:32
yes thanks now it compiles but the slot() won't close the window, ot i wonder if it's activated.



...
connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
this, SLOT( selmsg( const QModelIndex() ) ) );
}

//************************************************** **************
void Archives::selectmsg( const QModelIndex &idx )
{
accept();
close();
}
..

qArchiv is a QTreeview that I want to select.

munna
29th March 2006, 12:35
replace



connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
this, SLOT( selmsg( const QModelIndex() ) ) );


by



connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
this, SLOT( selmsg( const QModelIndex &) ) );


and then try.

incapacitant
29th March 2006, 12:44
connect( qArchiv, SIGNAL( clicked( QModelIndex &) ),
this, SLOT( close() ) );
thius won't even work !

zlatko
29th March 2006, 12:49
Signal and slot must have the same params

incapacitant
29th March 2006, 12:50
connect( qArchiv, SIGNAL( clicked( QModelIndex &) ),
this, SLOT( selectmsg( QModelIndex &) ) );
}
//************************************************** **************
void Archives::selectmsg( const QModelIndex &idx )
{
accept();
close();
}


does not close the dialog

zlatko
29th March 2006, 12:56
what about this?


connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
this, SLOT( selectmsg( const QModelIndex &) ) );

incapacitant
29th March 2006, 12:59
// setupViews
qArchiv = new QTreeView( this );
qArchiv->resize( QSize( 330, 112 ) );
qArchiv->move( 34, 71 );
qArchiv->setModel(model);
qArchiv->setEditTriggers( QAbstractItemView::NoEditTriggers );
qArchiv->setSelectionMode( QListView::SingleSelection );
qArchiv->header()->resizeSection( 0,110 );

QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
qArchiv->setSelectionModel(selectionModel);
qArchiv->setRootIsDecorated( false );

remplirArchiv();

// ok push button
pbOk = new QPushButton( "Ok", this);
pbOk->resize( QSize( 50, 20 ) );
pbOk->move( 300, 190 );

connect( pbOk, SIGNAL( clicked() ), this, SLOT( close() ) );
connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
this, SLOT( selectmsg( const QModelIndex &) ) );
}
//************************************************** **************
void Archives::selectmsg( const QModelIndex & idx )
{
accept();
close();
}


does not close the window, i don't understand

munna
29th March 2006, 13:04
in your .h file

replace


void selmsg( const QModelIndex() &);


by



private slots:
void selmsg( const QModelIndex &);

incapacitant
29th March 2006, 13:27
yes i keep forgetting they should be declared as private slots and not just privte. thx