Results 1 to 7 of 7

Thread: Qt Coding/Design Standards

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt Coding/Design Standards

    I was wondering if there are Qt coding standards out there that Troll Tech recommends when developing applications under its framework.

    For example I notice they do a lot of "camel humping", example: "testVariable".
    lol, sorry.. I just re-read the sentence above. Anyways...

    It is just something I am interested in from a software engineering stand point. It notice that it conflicts with my companies current notation.

    Also, for things like QTabWidgets... at first I put all of my components on each tab page. I realized that this was a very bad design decision because the .ui will create one class for the dialog which really hinders re-use and adaptability. Instead I am leaving these pages blank and adding a widget "frame" to each page so that each tab page has its own "frame" class.

    It is stuff like that, that interests me. I am curious if Troll Tech has any design recommendations. Layouts would be another thing. Do they recommend layouts all of the time, only in certain situations... how that is important for localization... etc.

    If anyone has any thoughts on this, I would love to hear them.

    Thanks.

  2. #2
    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: Qt Coding/Design Standards

    Trolltech does not recommend any particular programming style. What you choose is up to you.

    As for "camel humping", there tends to be three sorts of variable naming conventions:

    1) c_underlining: name_your_variables_like_this
    2) camelNotation: variablesThatHaveAHumpInTheMiddle
    3) mshNotation: Microsoft's Hungarian Notation

    The Hungarian Notation seems to be the most popular in Microsoft shops, because Microsoft used to heavily encourage it. But it's been shown to be counter productive. The prefixes are extraneous and if you don't get them exactly correct, you waste time in code review meetings correcting them.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Coding/Design Standards

    Quote Originally Posted by bpetty View Post
    Layouts would be another thing. Do they recommend layouts all of the time, only in certain situations... how that is important for localization... etc.
    I remember that this was discussed somewhere, but I don't remeber where. It might be in "C++ GUI Programming in Qt3", but I'm not sure. Anyway, when using layouts you can avoid some problems with localization, since widgets (especially labels) can adapt to text size, which might differ between languages.

    When it comes to naming conventions, read this: http://doc.trolltech.com/qq/qq13-apis.html --- the Trolls give some rationale behind naming conventions used in Qt.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Coding/Design Standards

    Quote Originally Posted by Brandybuck View Post
    Trolltech does not recommend any particular programming style. What you choose is up to you.
    That's right and there always be someone that's not happy with the current style.

    Quote Originally Posted by Brandybuck View Post
    it's been shown to be counter productive.
    Also you don't need it in C++, because it has strict type checking in comparison to C for which than notation was invented.

  5. #5
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Coding/Design Standards

    The link that jacek provided is a must read if you are using Qt. This will save you from inconsistent naming of the underlying framework with your code. Believe me it's a relief, the code becomes readable from the one instant to the other. I am also quite a huge fun of the convention used in http://www.javaranch.com/style.jsp although java centric and although I just can't lose the m_ prefix (yet?). But I 'm a huge Kathy Sierra fan so go figure
    In any case if you are using a base toolkit that will appear everywhere in your code, stick with the toolkit naming conventions...
    I love deadlines. I like the whooshing sound they make as they fly by.
    --
    Douglas Adams

  6. #6
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Coding/Design Standards

    I do not know what "notation" or "style" this is, but the standard, or more OO way to code, is naming variables like so:

    QTabWidget that is in a class:
    m_TabWconversations;

    Standard stuff in a class:
    int m_iNum;
    char m_cName;

    standard stuff not in a class:
    int iNum;
    double dbDigits;
    QPushButton qpbQuit;

  7. #7
    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: Qt Coding/Design Standards

    The last part looks like the hungarian notation and it's definitely not object-oriented and also not a standard for c++. It was created for C Windows programming and is widely explained in Paetzold's book (sorry if I mispelled the name, I don't have the book).

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.