Results 1 to 2 of 2

Thread: Code design QVariant or template<class T>

  1. #1
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Code design QVariant or template<class T>

    Hello, i've a problem with my code design. I've read this manual about QVariant: http://doc.trolltech.com/4.3/qvariant.html

    Waht is the diffrent between code1 and code2?

    code1:
    Qt Code:
    1. QString CMainWindow::myFunction( QVariant num ) {
    2. QString tmp;
    3. // do something
    4.  
    5. return tmp;
    6. }
    To copy to clipboard, switch view to plain text mode 

    code2:
    Qt Code:
    1. template <class T> QString CMainWindow::myFunction( T num ) {
    2. QString tmp;
    3. // do something
    4.  
    5. return tmp;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Is code1 the same as code2 only in Qt-Style?

    so long

    jd
    The most difficult in the world is to live in it

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Code design QVariant or template<class T>

    code1 is a single method handling all registered types. code2 is a series of methods for different datatypes.

Similar Threads

  1. Dialog and code design issue
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2006, 17:54
  2. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41

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.