Hm, there is something else going wrong...could you please have a look into the code? I initialized the pointer but the application is still crashing at the same spot.
mainwindow.h
QStandardItemModel *model_customer;
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
MainWindow
::MainWindow(QWidget *parent
){
...
setupModels();
...
}
void MainWindow::setupModels()
{
}
void MainWindow::newcustomer() //called with a QPushButton
{
AddressNew *newcustomer = new AddressNew(this);
if (newcustomer->exec())
{
newcustomer->addToModel(model_customer);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
...
setupModels();
...
}
void MainWindow::setupModels()
{
QStandardItemModel *model_customer = new QStandardItemModel;
}
void MainWindow::newcustomer() //called with a QPushButton
{
AddressNew *newcustomer = new AddressNew(this);
if (newcustomer->exec())
{
newcustomer->addToModel(model_customer);
}
To copy to clipboard, switch view to plain text mode
AddressNew.h
void setMap(QStandardItemModel* model);
To copy to clipboard, switch view to plain text mode
AddressNew.cpp
QMap<QString, QString> map; //contains QStrings from QLineEdits
QMapIterator<QString, QString> i(map);
QList<QStandardItem*> rowList;
while (i.hasNext()) {
i.next();
}
item->appendRow(rowList);
void AddressNew::setMap(QStandardItemModel* model)
QMap<QString, QString> map; //contains QStrings from QLineEdits
QMapIterator<QString, QString> i(map);
QList<QStandardItem*> rowList;
QStandardItemModel* test = new QStandardItemModel;
QStandardItem *item = model->invisibleRootItem();
while (i.hasNext()) {
i.next();
rowList << new QStandardItem(i.value());
}
item->appendRow(rowList);
To copy to clipboard, switch view to plain text mode
Any ideas?
Bookmarks