Results 1 to 2 of 2

Thread: What does it mean by "value class" ?

  1. #1
    Join Date
    Aug 2010
    Posts
    22
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default What does it mean by "value class" ?

    The Assistant said:
    "QSqlDatabase is a value class. Changes made to a database connection via one instance of QSqlDatabase will affect other instances of QSqlDatabase that represent the same connection."

    What does it mean by "value class"?
    I only have one database connection in my application. Should I use a pointer to it everywhere in the program? Or shouldn't I?

    Qt Code:
    1. class MyApp1:public QApplication {
    2.  
    3. public:
    4. QSqlDatabase db() {
    5. return db;
    6. }
    7.  
    8. private:
    9. }
    10.  
    11.  
    12. class MyApp2:public QApplication {
    13.  
    14. public:
    15. QSqlDatabase *db() {
    16. return &db;
    17. }
    18.  
    19. private:
    20. }
    To copy to clipboard, switch view to plain text mode 
    Which is better? MyApp1 or MyApp2 ?

    Thanks !

  2. #2
    Join Date
    Aug 2009
    Location
    Greece, Chania
    Posts
    63
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: What does it mean by "value class" ?

    http://drdobbs.com/184401955

    You don't need to store anything, a simple call to QSqlDatabase::database() is enough in most cases.
    Misha R.evolution - High level Debugging IDE

    Programming is about 2 basic principles: KISS and RTFM!!!

  3. The following user says thank you to Archimedes for this useful post:

    jezz (11th April 2011)

Similar Threads

  1. "Incomplete" Event class types [solved]
    By Live-Dimension in forum Qt Programming
    Replies: 2
    Last Post: 5th August 2010, 13:59
  2. debugging "signal does not reach slot" in a template class
    By Daniel Dekkers in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2010, 16:03
  3. Replies: 4
    Last Post: 19th March 2008, 17:47
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. Replies: 2
    Last Post: 25th August 2006, 11:35

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.