Qt and opengl

Started by
10 comments, last by the_edd 13 years, 2 months ago

[quote name='Seaßourne' timestamp='1296635649' post='4768376']
I see a lot of things wrong with your code.


I'd appreciate it if you could point out my errors to me. :) I in no way claim to be an Ogre / Qt expert, and it is entirely possible that I'm doing things completely wrong.
[/quote]

1. You don't need boost::noncopyable as you can use: http://doc.qt.nokia.com/4.7/qobject.html#Q_DISABLE_COPY

class OrgeWidget {
private:
Q_DISABLE_COPY(OrgeWidget)
};


2. Your constructor should be QtOgreWidget(QWidget* parent = 0); not with reference and it should be the last parameter with exactly QWidget* parent = 0 (Qt uses 0 instead of NULL)

3. Qt already has macros for assertion Q_ASSERT (plain assert) and Q_ASSERT_X (with a message)
http://doc.qt.nokia....l.html#Q_ASSERT
http://doc.qt.nokia....html#Q_ASSERT_X

4. You should be using QString instead of std::ostringstream to convert data like numbers, appending, etc.

QString::number(20) == "20" etc.
QString("Foo %1 and %2").arg("foo", "bar"); // "Foo foo and bar"

http://doc.qt.nokia....st/qstring.html

5. Qt already has it's own containers, QList, QVector, QHash, QMap, QMultiMap, QMultiHash, QLinkedList, etc

6. Qt already has stream classes QTextStream and QDataStream with great unicode support. Maybe should convert to it.

7. Not sure what TXT_() is and if thats for translating like L"" etc are. Then there is tr() for it which you can use Linguist with to translate.

8. You shouldn't prefix classes with Qt as it's reserved naming convention same with QFoo.
Advertisement
Many of those complaints are really about style.

Some people like to use Qt as an implementation detail of the GUI rather than spreading Qt code all throughout the application. There are often good reasons to choose non-Qt stuff over Qt stuff and vice-versa, but that's an engineering decision to be made based on the merits of each. I wouldn't dare to call those things "wrong" without knowing the complete picture.

I don't see anything fundamentally unsound with Red Ant's contribution. IMHO, it's the most helpful and direct piece of advice given in the thread so far.

This topic is closed to new replies.

Advertisement