PDA

View Full Version : Making global QStandardItemModel



SykeS
7th May 2010, 11:00
Hi!

I'm trying to introduce myself to QT. I want to make a simple program with two main functions: 1). managing contacts, 2). creating PDF with details of chosen contact. I read about model/view programming in QT and I know I have to use QStandardItemModel, but: where I have to define and implement my model if I want to access it from all dialogs in my app? How to access it?

Cheers,
David

JD2000
7th May 2010, 18:46
In this case I would put the model code in mainwindow.cpp

Each dialogue is generally implemented as a separate class and #included in mainwindow.

so you can have something like


void MainWindow::on_NewContactButton_clicked()
{
newContactDialog ncd(this);
}

and the model would be accessable to ncd.

Incidentally, you have not mentioned where you are storing your contacts, if you are using a database you may be better off using a prebuilt model such as QSqlQueryModel.