View Full Version : query about best practices
Raajesh
13th June 2008, 14:52
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
wysota
13th June 2008, 15:06
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.
momesana
13th June 2008, 15:08
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.
Brandybuck
13th June 2008, 18:47
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.