Hello anyone,
I ám using fc6 with Qt-4.2
I have a Dialog with a freesTable widget with 1 collum.
I can add a row through a another Dialog into freesTable no problem.
I want to hold the row in a QList<> and when i startup the application it will iterate first
through the QList and place the row in my freesTable.
But there is nothing showing up in freesTable.
Can anybody help me with this problem.
The header file frees.h
#include <QtGui>
#include "ui_freesdialog.h"
class freesDialog
: public QDialog,
public Ui
::freesDialog{
Q_OBJECT
public:
freesDialog
(QList<QString>
*list,
QWidget *parent
=0);
public slots:
void add();
private slots:
void done(int result);
private:
QList<QString> list;
};
#include <QtGui>
#include "ui_freesdialog.h"
class freesDialog : public QDialog, public Ui::freesDialog
{
Q_OBJECT
public:
freesDialog(QList<QString> *list, QWidget *parent=0);
public slots:
void add();
private slots:
void done(int result);
private:
QList<QString> list;
};
To copy to clipboard, switch view to plain text mode
The implentation file frees.cpp
#include <QtCore>
#include "frees.h"
#include "frezen.h"
freesDialog
::freesDialog(QList<QString>
*list,
QWidget *parent
)
{
setupUi(this);
for(int row = 0; row < list->count(); ++row) {
freesTable
->setItem
(row,
0,
new QTableWidgetItem(frees
));
//Something is wrong here.}
connect(pbAdd, SIGNAL(clicked()), this, SLOT(add()));
connect(pbRemove, SIGNAL(clicked()), this, SLOT(remove()));
}
void freesDialog::add()
{
frezenDialog dlg(this);
if( dlg.
exec() == QDialog::Accepted ) {
QString materiaal
= dlg.
matComboBox->currentText
();
int row = freesTable->rowCount();
freesTable->insertRow(row);
}
}
void freesDialog::done(int result)
{
for(int row = 0; row < freesTable->rowCount(); ++row) {
QString materiaal
= freesTable
->item
(row,
0)->text
();
list.
append(QString(materiaal
));
// Give a error Undefined reference to Frezen::Frezen(QString const&) }
}
}
#include <QtCore>
#include "frees.h"
#include "frezen.h"
freesDialog::freesDialog(QList<QString> *list, QWidget *parent)
:QDialog(parent)
{
setupUi(this);
for(int row = 0; row < list->count(); ++row) {
QString frees = list->at(row);
freesTable->setItem(row, 0, new QTableWidgetItem(frees)); //Something is wrong here.
}
connect(pbAdd, SIGNAL(clicked()), this, SLOT(add()));
connect(pbRemove, SIGNAL(clicked()), this, SLOT(remove()));
}
void freesDialog::add()
{
frezenDialog dlg(this);
if( dlg.exec() == QDialog::Accepted ) {
QString materiaal = dlg.matComboBox->currentText();
int row = freesTable->rowCount();
freesTable->insertRow(row);
freesTable->setItem(row, 0, new QTableWidgetItem(materiaal));
}
}
void freesDialog::done(int result)
{
if(result == QDialog::Accepted) {
for(int row = 0; row < freesTable->rowCount(); ++row) {
QString materiaal = freesTable->item(row, 0)->text();
list.append(QString(materiaal)); // Give a error Undefined reference to Frezen::Frezen(QString const&)
}
}
QDialog::done(result);
}
To copy to clipboard, switch view to plain text mode
The main file main.cpp
#include <QApplication>
#include "frees.h"
int main(int argc, char *argv[])
{
QList<Frezen> list;
freesDialog freesdlg(&list);
return freesdlg.exec();
}
#include <QApplication>
#include "frees.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QList<Frezen> list;
freesDialog freesdlg(&list);
return freesdlg.exec();
}
To copy to clipboard, switch view to plain text mode
Thanks in advance.
Bookmarks