Philipp Thomas wrote:
As my crystal ball is out for repair, could you please post the code g++ is
complaining about together with g++'s warnings? Without seeing both there
isn't much we could tell you.
Ok i post my code then, see below :)
Stefan Hundhammer wrote:
You have to specify constructors for your classes derived of QWidget and
related. Make sure you call the parent class constructor first. Otherwise
most of the Qt internal stuff would not work.
Most Qt classes intentionally don't provide a default constructor (one that
does not receive any argument) because of this.
You don't need all the variety of constructors that Qt classes provide, but at
least one - preferably one that at least accepts a "parent" argument so the
Qt widget hierarchy logic remains intact. As an added benefit, Qt will take
care of cleaning up widgets that have a parent when you delete the parent (or
the grandparent etc.).
I hope i am correct in my following code.
I want to override only paintCell of QListViewItem class.
/******** myListViewItem.h ******/
#ifndef MY_LIST_VIEW_ITEM_H
#define MY_LIST_VIEW_ITEM_H
#include
#include
#include <string>
#include <iostream>
class myListViewItem : public QListViewItem
{
public:
myListViewItem(QListView * parent, QString, QString ,QString , QString ,
QString , QString ,
QString , QString );
myListViewItem(myListViewItem * parent, QString, QString ,QString , QString ,
QString , QString ,
QString , QString );
myListViewItem(myListViewItem * parent );
void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align );
};
#endif
/***************************************************/
/******** myListViewItem.cpp ******/
#include "myListViewItem.h"
myListViewItem::myListViewItem( QListView * parent,
QString s1, QString s3 = QString::null,
QString s4 = QString::null, QString s5 = QString::null,
QString s6 = QString::null, QString s7 = QString::null,
QString s8 = QString::null, QString s9 = QString::null
)
:QListViewItem(parent, s1)
{
;
}
myListViewItem::myListViewItem( myListViewItem * parent,
QString s1, QString s3 = QString::null,
QString s4 = QString::null, QString s5 = QString::null,
QString s6 = QString::null, QString s7 = QString::null,
QString s8 = QString::null, QString s9 = QString::null
)
:QListViewItem(parent, s1)
{
;
}
myListViewItem::myListViewItem(myListViewItem * parent )
:QListViewItem(parent)
{
;
}
void myListViewItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align)
{
//do some funny stuff here...
}
/*****************************************************/
So i do the following in another source file:
myListViewItem* itemChild;
vector <QString> neededLibVector;
new myListViewItem(itemChild, neededLibVector[i].ascii());
so the compiler says :
no matching function for call to
`myListViewItem::myListViewItem(myListViewItem*&, const char*)'
myListViewItem.h:11: candidates are: myListViewItem::myListViewItem(const myListViewItem&)
myListViewItem.h:22: myListViewItem::myListViewItem(myListViewItem*)
myListViewItem.h:20: myListViewItem::myListViewItem(myListViewItem*, QString, QString, QString,
QString, QString, QString, QString, QString)
myListViewItem.h:16: myListViewItem::myListViewItem(QListView*, QString, QString, QString,
QString, QString, QString, QString, QString)
The point is that when i do :
QListViewItem* itemChild;
vector <QString> neededLibVector;
new QListViewItem(itemChild, neededLibVector[i].ascii());
the compiler is happy about it ...
Thanks.
Filip