PDA

View Full Version : QList problem



frenk_castle
18th January 2010, 22:05
Problem is probably stupid but so far I failed to find what I am doing wrong.

I have in my project these two classes:



class RegularJobLayout : public QHBoxLayout
{
Q_OBJECT

public:
RegularJobLayout(const QString &title, const int index, QWidget *parent = 0);

protected slots:
void setPrintSlot();
void setPackSlot();
void setProcessSlot();

protected:
void setJobLayout(const QString &title);
void setJobGroupBox(const QString &title);

void initializePrintModel();
QStandardItem* initializeTwinItem(QStandardItem *parent);
QStandardItem* initialize3110Item(QStandardItem *parent);
QStandardItem* initializeCPSItem(QStandardItem *parent);

void initializePackModel();
QStandardItem* initializePackItem(QStandardItem *parent);

QStandardItem* initializePrintPackChildItem(QStandardItem *parent);

void initializeProcessingModel();

int m_index;

QLabel *m_jobNameLabel;
QLineEdit *m_jobNameLineEdit;

QLabel *m_userCountLabel;
QSpinBox *m_userCountSpinBox;

QLabel *m_duplexLabel;
QComboBox *m_duplexComboBox;

QLabel *m_resolutionLabel;
QComboBox *m_resolutionComboBox;

QLabel *m_deliveryLabel;
QComboBox *m_deliveryComboBox;

QLabel *m_shipmentLabel;
QComboBox *m_shipmentComboBox;

QTreeView *m_printTreeView;
QStandardItemModel *m_printItemModel;
QPushButton *m_printButton;

QTreeView *m_packTreeView;
QStandardItemModel *m_packItemModel;
QPushButton *m_packButton;

QTreeView *m_processingTreeView;
QStandardItemModel *m_processingItemModel;
QPushButton *m_processingButton;

QGroupBox *m_jobGroupBox;
QGridLayout *m_jobGroupBoxLayout;

QSpacerItem *m_leftJobSpacerItem;
QSpacerItem *m_rightJobSpacerItem;
};

class RegularCentralWidget : public QWidget
{
Q_OBJECT

public:
RegularCentralWidget(QWidget *parent = 0);

protected:
RegularHeaderLayout *m_headerLayout;

QList<RegularJobLayout> *m_jobList;

QVBoxLayout *m_layout;
};


I had five separate RegularJobLayout pointers in my RegularCentralWidget class but decided that this is a more professional approach. Easier to update my code at later time. In the constructor I have the following code:



RegularCentralWidget::RegularCentralWidget(QWidget *parent) : QWidget(parent)
{
m_headerLayout = new RegularHeaderLayout();

m_layout = new QVBoxLayout(this);

m_layout->addLayout(m_headerLayout);

int index, maxJobs = 5;
QString title;

m_jobList = new QList<RegularJobLayout>();

for(index = 0; index < maxJobs; ++index)
{
title.setNum(index+1);
title.prepend("Posao ");

m_jobList->append(new RegularJobLayout(title, index)); //This line fails

m_layout->addLayout(m_jobList[index]); //This line fails
}
}


Constructor can probably be better but I am still trying to make it work. I get the following errors:

/home/ivan/Development/Qt/RadniNalog/WorkOrder0.2.3/wouil.cpp:155: error: no matching function for call to ‘QList<telekom::workorder::RegularJobLayout>::append(telekom::workorder::RegularJobLayout*)â⠂¬â„¢
/usr/include/qt4/QtCore/qlist.h:422: note: candidates are: void QList<T>::append(const T&) [with T = telekom::workorder::RegularJobLayout]
/usr/include/qt4/QtCore/qlist.h:623: note: void QList<T>::append(const QList<T>&) [with T = telekom::workorder::RegularJobLayout]
/home/ivan/Development/Qt/RadniNalog/WorkOrder0.2.3/wouil.cpp:157: error: no matching function for call to ‘QVBoxLayout::addLayout(QList<telekom::workorder::RegularJobLayout>&)’
/usr/include/qt4/QtGui/qboxlayout.h:86: note: candidates are: void QBoxLayout::addLayout(QLayout*, int)

If somebody would help me to figure out where am I making a mistake I would really appreciate it.

Thanks in advance.

frenk_castle
19th January 2010, 05:40
I went to sleep and when I woke up I figured out that I forgot the *. It should be QList<RegularJobLayout*>. Stupid mistake.