Results 1 to 11 of 11

Thread: Very new Qt user (couple of questions at end of message)

  1. #1
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Cool Very new Qt user (couple of questions at end of message)

    Good evening,

    I've been wanting to build my own application and wanted to make it cross platform and multi lingual if possible.

    A while ago I did I quick evaluation of cross platform libraries and decided upon wxWidgets. I wasn't that keen on Qt because I had heard about the need to write impure C++ that gets run through a processor before the compiler sees it. The use of macros and global variables dissuaded me too.

    After getting into the application, and using more and more of the wxWidgets library I'm having serious reservations about it. The wxAui ("Advanced User Interface") library I wanted to make heavy use of seems incomplete and awkward. Purpose of the message is not really to criticise that project but to say I'm going to give Qt a whirl!

    Going through the tutorial at the moment. A lot of time seems to be spent on the tutorials which is a really good sign Have downloaded the SDK for Windows and it compiled and ran programs straight away which is a very encouraging! The IDE looks pretty good and I'm looking forward to learning and becoming proficient ASAP.

    I was surprised to see the tr() function wrapping a string literal. For internationalisation I would've expected to see an integral value referencing an entry in a string table. I'm keen to see how the i18n works. Can anyone tell me in a nutshell?

    My application will be using a number of double-buffered OpenGL windows. I've seen there's a number of OpenGL examples. What essentially needs to be done to make a window drawable with OpenGL?

    Thanks,

    PUK

  2. #2
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Very new Qt user (couple of questions at end of message)

    Hi Puck,

    I too was keen on WxWidgets, having quickly tried Qt I went with Wx for a while but found Qt better for my purpose, and since Qt Creator I don't think there's anything easier.

    The docs are excellent, have a look in there for your answers. Here's the online links:

    http://doc.trolltech.com/4.5/i18n.html
    http://doc.trolltech.com/4.5/qtopengl.html

  3. The following user says thank you to vieraci for this useful post:

    PUK_999 (4th August 2009)

  4. #3
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Appreciate the reply and the links. I'm sure I'll be back sometime in the future for more answers when I get deeper into the app.

    Pete

  5. #4
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Quote Originally Posted by PUK_999 View Post
    I wasn't that keen on Qt because I had heard about the need to write impure C++ that gets run through a processor before the compiler sees it. The use of macros and global variables dissuaded me too.
    It's a necessary trade-off for cool things like introspection. The preprocessor (meta-object compiler) works great. Don't be scared of it

    Quote Originally Posted by PUK_999 View Post
    I was surprised to see the tr() function wrapping a string literal. For internationalisation I would've expected to see an integral value referencing an entry in a string table. I'm keen to see how the i18n works. Can anyone tell me in a nutshell?
    You'll often use Qt Linguist to create the actual translations. Qt Linguist will extract all the tr() (and some other to-be-translated strings like strings in your .ui files) and give you an interface for translating your apps. Linguist is quite useful. It automatically detects which strings have changed or were added at a later time, for example. It also matches your wording to previous strings. Translations also support arguments etc. See the Linguist manual for more info - it is a very complete manual http://doc.trolltech.com/4.5/linguist-manual.html

    Quote Originally Posted by PUK_999 View Post
    My application will be using a number of double-buffered OpenGL windows. I've seen there's a number of OpenGL examples. What essentially needs to be done to make a window drawable with OpenGL?
    You basically just have to create a widget which inherits from QGLWidget, and that's it OpenGL initialization should then take place in a reimplemented initGL() function and painting should happen in a reimplemented paintGL() function - although you can also do very cool stuff like mix QPainter's 2D painting API with OpenGL and render it all with OpenGL acceleration (see the overpainting example) or use the QGraphicsView with a QGLWidget viewport to render it all in OpenGL automatically. Qt provides very advanced features for these kinds of things actually -- it also just so happens that I started porting the NeHe tutorials to Qt 4, so if you want to see how to start with OpenGL stuff in Qt, you could take a look at it if you want - http://wesley.vidiqatch.org/03-08-20...apter-1-and-2/

  6. The following user says thank you to profoX for this useful post:

    PUK_999 (4th August 2009)

  7. #5
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Quote Originally Posted by vieraci View Post
    The docs are excellent, have a look in there for your answers. Here's the online links:

    http://doc.trolltech.com/4.5/i18n.html
    Just read that resource. I'm really impressed! Looks well thought out. Some points I really liked:

    • Disambiguation (context) string is great.
    • Insertion of runtime variables into the string at different positions in different translations (sprintf() ish but just on position, not on type) is a good solution.
    • The pipeline from lupdate -> Linguist -> lrelease and the use of the XML format for the .ts files makes it so understandable.
    • QString, QChar and the UTF-8 conversion support will be really handy.
    • LanguageChangeEvent being posted around to widgets to change language at runtime is brilliant.
    • The idea of QTranslation representing a translation file, the ability to load multiple ones, and the search backward from most recently loaded algorithm could really help with avoiding monolithic and using more modular translation files.


    PUK

  8. #6
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Quote Originally Posted by profoX View Post
    It's a necessary trade-off for cool things like introspection. The preprocessor (meta-object compiler) works great. Don't be scared of it
    I am prepared to embrace the Qt way of doing things and will also try to isolate the Qt code from the "business logic" as much as possible so the macros, etc are mainly in the UI area

    You'll often use Qt Linguist to create the actual translations. Qt Linguist will extract all the tr() (and some other to-be-translated strings like strings in your .ui files) and give you an interface for translating your apps. Linguist is quite useful. It automatically detects which strings have changed or were added at a later time, for example. It also matches your wording to previous strings. Translations also support arguments etc. See the Linguist manual for more info - it is a very complete manual http://doc.trolltech.com/4.5/linguist-manual.html
    Just been reading the i18n page. Great. Had a quick glance at the Linguist page. Looks like a good tool that I'll get into a bit deeper later. I'm really happy that my i18n requirements will be catered for. Will be interesting to see how it works with source code that has been hacked about a bit with regards to recognising strings it's already encountered that have changed slightly.

    You basically just have to create a widget which inherits from QGLWidget, and that's it OpenGL initialization should then take place in a reimplemented initGL() function and painting should happen in a reimplemented paintGL() function - although you can also do very cool stuff like mix QPainter's 2D painting API with OpenGL and render it all with OpenGL acceleration (see the overpainting example) or use the QGraphicsView with a QGLWidget viewport to render it all in OpenGL automatically. Qt provides very advanced features for these kinds of things actually -- it also just so happens that I started porting the NeHe tutorials to Qt 4, so if you want to see how to start with OpenGL stuff in Qt, you could take a look at it if you want - http://wesley.vidiqatch.org/03-08-20...apter-1-and-2/
    Thank you very much! I'm excited about what you mentioned w.r.t QPainter's 2D API. My app will be doing 3D mainly, but in the corners of the viewing area I will want to draw some extra information. For instance - projection name or viewport name. Doing text in GL can be a pain, especially if it's translated. I'm hoping QPainter::drawText() might take care of this for me (at least).

    PUK

  9. #7
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Quote Originally Posted by PUK_999 View Post
    Thank you very much! I'm excited about what you mentioned w.r.t QPainter's 2D API. My app will be doing 3D mainly, but in the corners of the viewing area I will want to draw some extra information. For instance - projection name or viewport name. Doing text in GL can be a pain, especially if it's translated. I'm hoping QPainter::drawText() might take care of this for me (at least).

    PUK
    For basic text, QGLWidget::renderText() will suffice though it can render text at a random location on your QGLWiget for information, and it optionally takes the OpenGL transformation into account as well so that you can label things in the OpenGL scene.

    But with overpainting using QPainter yourself, the possibilities are endless... even more so when putting QGraphicsView in the mix, you'll be able to render OpenGL + QPainter stuff AND integrate and transform normal widgets in your scene it's really absolutely beautiful. Take a look at what I mean:
    http://doc.qtsoftware.com/4.6-snapshot/demos-boxes.html (especially this demo)
    http://doc.qtsoftware.com/4.6-snapsh...eddialogs.html
    http://labs.trolltech.com/blogs/2008...sion-wolfenqt/
    http://labs.trolltech.com/blogs/2008...s-with-opengl/

    Also, here are some simple OpenGL examples:
    http://doc.qtsoftware.com/4.6-snapsh...es.html#opengl

    I used to play around with the QGraphicsView a lot when it was just released By combining/modifying the Phonon media player and embedded widgets demos I created something rather cool: http://www.youtube.com/watch?v=nZWHlVMe-u0&fmt=18 it's rendered in OpenGL and everything, but the funny thing is that I didn't have to write 1 line of OpenGL. The QGraphicsView is able to translate everything to OpenGL itself

  10. #8
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Took a quick look at WolfenQt. Looks amazing what is possible!

    The screenshot from the Boxes demo looks gorgeous. Is there a quick way to get the source files to my computer rather than downloading them one-by-one? I want to compile/run/play with it. Ahh - just realised the image files referenced by boxes.qrc won't be present so I probably wont be able to do it.

    I'm going through the Qt fundamentals tutorial and I'm at the stage that they're multi-file so it'd be nice to download all project files in one go.

    The embedded media player video looks really good.

    Thanks for sharing,

    PUK

  11. #9
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    I'm not sure what OS you are running, but you can always download the Qt SDK which contains everything you will need including all the demos and examples, all the necessary tools, and the new Qt Creator IDE.

    That Qt Fundamentals tutorial is not that good by the way. They removed the tutorial from the 4.5 documentation. The tutorial is a bit old-school and does not teach you how to really use Qt efficiently (eg. by using the Designer component etc) -- but of course you're bound to learn a lot of key concepts with it anyway

    If you're really serious about Qt, I can recommend this on line book - http://cartan.cas.suffolk.edu/oopdocbook/opensource/ (more info at http://cartan.cas.suffolk.edu/moin/OopDocbookWiki) - it is very extensive, it's actually a real book which has been released for free on line now you might want to skip some of the first chapters though, as they deal with Qt for command line applications. The book is from before the Qt SDK and Qt Creator were available, so the chapters about installation are not important anymore. These days you can just grab the Qt SDK, install it, and you're done with the installation procedure - no matter what your platform is

    edit: I should note that the book might be less interesting if you're already very familiar with C++, because the book also tries to teach you C++ and design patterns along the way

    edit again: sorry, by rereading your first post I see that you use Windows and you've already downloaded the SDK. I'm pretty sure the examples should be available somewhere then browse through your Qt installation folder..
    Last edited by profoX; 5th August 2009 at 00:35.

  12. #10
    Join Date
    Aug 2009
    Posts
    30
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    I'm finding the fundamentals quite useful. Half way through now. It's getting me into signals/slots, I've used the Boost Signals library but interesting to see how heavily they're used in Qt and the differences in use. It's getting me into QPainter and other good stuff gently too.

    Been using C++ since DOS, TSRs, 16-bit Windows and have used design patterns so I'll probably not get too deeply into that book you mentioned.

    Here's the plan:

    • Finish fundamentals tutorial.
    • Take a look at widgets tutorial.
    • Don't think I'll be interested in the address book tutorial at the moment so skip that.
    • If the widgets tutorial doesn't cover the Designer, then go through the Designer manual.
    • Consider purchasing C++ GUI Programming with Qt 4, Second Edition or looking at the online version based on 4.1. I feel though that when at this stage I can probably just rely on the fabulous documentation, examples, and this forum.
    • Recreate the application I have already started in wxWidgets in Qt.
    • Finish application, makes lots of money and retire to island tax haven


    Cheers,

    PUK

  13. #11
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Very new Qt user (couple of questions at end of message)

    Haha, good luck with that last one

    To be honest, I only did a partial Qt tutorial once, and from then on I just went through the most interesting "Core features" and "Key technologies" pages in the Qt docs, and for the rest the docs have helped me with everything I really love the docs.

Similar Threads

  1. Logging Qt User Actions
    By Frank J. Lhota in forum Qt Programming
    Replies: 14
    Last Post: 30th May 2014, 22:36
  2. A couple of questions on installing Qt 4.5 on Windows Xp
    By rishiraj in forum Installation and Deployment
    Replies: 2
    Last Post: 3rd April 2009, 08:44
  3. treewidget and a message system
    By alisami in forum Qt Programming
    Replies: 7
    Last Post: 27th July 2008, 19:05
  4. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 20:03

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.