Results 1 to 4 of 4

Thread: Qt namespace Ui

  1. #1
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt namespace Ui

    Hi I would like to ask if it is possible to change the namespace 'Ui' generated by Qt to 'UI'. We are currently adhering to coding guidelines that makes use of all capital letters for abbreviations. When we tried this method:

    namespace UI
    {
    class frmMyDisplay;

    }

    ....also

    UI::frmMyDisplay


    ..it generates an error since the ui header generated by Qt makes use of the 'Ui' namespace when we build the project. It is possible by changing the namespace in the ui header generated by Qt to 'UI' but the problem will appear again once the project is rebuilt.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,688
    Thanks
    13
    Thanked 1,598 Times in 1,526 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt namespace Ui

    "Ui" is hardcoded into uic.

    Here are some options:
    • Change QMAKE_UIC in the pro file to point at a script that runs uic normally and then post-processes the output to change the namespace.
    • Make a modified uic that uses a different namespace name. You could even parameterise it and submit the modified version to the Qt project for the greater good.
    • Use a namespace alias to limit the "Ui" reference to once at the top of a file:
      Qt Code:
      1. using namespace UI = Ui; // to give us a coding standards compliant name
      To copy to clipboard, switch view to plain text mode 
    • Don't use Designer and uic; write your UI in code.
    • Convince management that spending time worrying about the capitalisation of a generated namespace name that is used in a handful of places in the code is detracting from actually making the program function.


    I predict the next argument will be over the naming of the retranslateUi() function in template form code.

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

    ehnuh (15th October 2012)

  4. #3
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt namespace Ui

    thanks for reply!

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt namespace Ui

    There is also this one stupid possibility:

    Qt Code:
    1. namespace UI {
    2. class Ui_xyz;
    3. };
    To copy to clipboard, switch view to plain text mode 

    or even this one (which can be autogenerated using some simple script):

    Qt Code:
    1. namespace UI {
    2. class xyz : public Ui::xyz {};
    3. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Example use namespace
    By giorgik in forum Newbie
    Replies: 4
    Last Post: 19th June 2012, 23:03
  2. Ui namespace
    By ashboi in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2012, 01:00
  3. using namespace VS using
    By jryans10 in forum General Programming
    Replies: 1
    Last Post: 7th January 2012, 23:23
  4. QTM namespace
    By Aman607 in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2011, 09:00
  5. QTest Namespace
    By chandan in forum Newbie
    Replies: 2
    Last Post: 4th October 2010, 10:45

Tags for this Thread

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.