Results 1 to 4 of 4

Thread: query about best practices

  1. #1
    Join Date
    May 2008
    Posts
    12
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default query about best practices

    Hi all,

    Is it a good practice to use pure c++ code in Qt, I mean stuff like,
    FILE *,std::string,fread,fclose. Can some body explain on this.

    Thanks,
    Raajesh

  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: query about best practices

    Most of the things you mentioned are actually C-originated (apart from std::string). Yes, you may use them if they fit your needs. Using QFile instead would give you some benefits, but if you feel confident with stdio.h, I don't see a reason not to use it.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: query about best practices

    I don't think so. You should use Qt's own facilities whenever feasible. For example using QFile and it's open() close() members and also Qt's own container classes. This will make your code easier to read by fellow Qt programmers.

  4. #4
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: query about best practices

    The "pure" C/C++ tends to be at a much lower level, so it is harder to use. Also, most are from C, and have no objectness. How do you inherit from FILE?

    In my opinion, when Qt gives you the same functionality that is easier to use with more features, then use the Qt class. Use QFile instead of FILE. QTextStream instead of iostream. QString instead of std::string. Etc.

Similar Threads

  1. Sql Query Problem
    By MrShahi in forum Qt Programming
    Replies: 6
    Last Post: 30th May 2008, 10:16
  2. Mysql query question
    By twells55555 in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2007, 00:41
  3. Aborting a query set on a TableModel
    By Quid in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2006, 23:36
  4. combining query lists
    By jayw710 in forum Qt Programming
    Replies: 4
    Last Post: 10th February 2006, 22:17
  5. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 19:50

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.