Results 1 to 2 of 2

Thread: Making global QStandardItemModel

  1. #1
    Join Date
    May 2010
    Location
    Rzeszow/Poland
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Making global QStandardItemModel

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Making global QStandardItemModel

    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

    Qt Code:
    1. void MainWindow::on_NewContactButton_clicked()
    2. {
    3. newContactDialog ncd(this);
    4. }
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. QDevelop - global variables & help
    By impeteperry in forum Qt-based Software
    Replies: 2
    Last Post: 9th June 2011, 23:28
  2. Passing global defines to moc
    By NTwoO in forum Qt Programming
    Replies: 6
    Last Post: 2nd April 2007, 11:23
  3. global variable
    By Shuchi Agrawal in forum General Programming
    Replies: 10
    Last Post: 15th February 2007, 04:19
  4. Qt and global variables
    By Morea in forum Qt Programming
    Replies: 11
    Last Post: 1st February 2007, 23:42
  5. Global variables
    By Mariane in forum Newbie
    Replies: 14
    Last Post: 10th October 2006, 17:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.