Ok, here are some code snippets from the application. . .
In MDI MainWindow:
void MainWindow::createMdiPrevQSOs()
{
// show the window
mdiPrev = new mdiPrevQSOs;
mdiArea->addSubWindow(mdiPrev);
mdiPrev->show();
}
void MainWindow::createMdiPrevQSOs()
{
// show the window
mdiPrev = new mdiPrevQSOs;
mdiArea->addSubWindow(mdiPrev);
mdiPrev->show();
}
To copy to clipboard, switch view to plain text mode
long after creation:
void MainWindow::slotUpdatePrev()
{
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
foreach (QMdiSubWindow *window, mdiArea->subWindowList())
{
if (window->windowTitle().startsWith(tr("Previous"),Qt::CaseInsensitive))
{
mdiPrevQSOs *child = qobject_cast<mdiPrevQSOs *>(window);
if (child->findPrev()) // (debug shows seg fault previous step is here)
{
. . .
}
}
}
. . .
}
void MainWindow::slotUpdatePrev()
{
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
foreach (QMdiSubWindow *window, mdiArea->subWindowList())
{
if (window->windowTitle().startsWith(tr("Previous"),Qt::CaseInsensitive))
{
mdiPrevQSOs *child = qobject_cast<mdiPrevQSOs *>(window);
if (child->findPrev()) // (debug shows seg fault previous step is here)
{
. . .
}
}
}
. . .
}
To copy to clipboard, switch view to plain text mode
the MDISubWindow has a list Widget that is filled by the called function.
mdiPrevQSOs constructor:
{
setAttribute(Qt::WA_DeleteOnClose);
. . .
widget
->setObjectName
(QString::fromUtf8("widget"));
. . .
listView
->setObjectName
(QString::fromUtf8("listView"));
}
mdiPrevQSOs::mdiPrevQSOs(QWidget *parent) : QDialog(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
. . .
widget = new QWidget(this);
widget->setObjectName(QString::fromUtf8("widget"));
. . .
listView = new QTreeView(widget);
listView->setObjectName(QString::fromUtf8("listView"));
}
To copy to clipboard, switch view to plain text mode
the public function called:
bool mdiPrevQSOs::findPrev()
{
. . .
// create a query . . .
// create a QStandardItemModel for the tree view. . .
// fill the model with data from the query . . .
. . .
// (this line crashes with a seg fault)
listView->setModel(s_model); // the tree view created in the constructor
. . .
}
bool mdiPrevQSOs::findPrev()
{
. . .
// create a query . . .
// create a QStandardItemModel for the tree view. . .
// fill the model with data from the query . . .
. . .
// (this line crashes with a seg fault)
listView->setModel(s_model); // the tree view created in the constructor
. . .
}
To copy to clipboard, switch view to plain text mode
Bookmarks