uic and namespace



  • Hello, developers. Now I have another question. Is it possible to add extra namespace in the uic-generated class?


  • Moderators

    @trialuser

    What do you have in mind by this?

    uic-generated classes are based on ui files which you basically edit with Qt designer. All this is helping you in streamlining your implementation. You can handle all of the work done by Qt designer by yourself as some developers prefer to do. On the other hand Qt designer is also meant to take this coding away and assist the programmer with wysiwyg feature.

    AFAIK there is no way to add something from outside to the generated classes and in my opinion this perfect, because otherwise it might get really messy. If you like to use Qt creator for part of your coding, but you need to extend, it is the better way to inherit from generated classes rather than trying to push more into it.


  • Qt Champions 2016

    @trialuser
    Hi,
    This is follow up for your previous question, right?
    No, sadly you can't make uic generate the classes in a different namespace, and you can't instruct it to (not-)export them. I had a similar, although not quite severe, problem as you and ultimately I haven't found any satisfactory solution.

    @koahnig

    AFAIK there is no way to add something from outside to the generated classes and in my opinion this perfect, because otherwise it might get really messy.

    The problem is on Linux the exported symbols are a real mess and there's no good way to hide the things generated by uic that shouldn't be visible in the first place.

    Kind regards.


  • Moderators

    @kshegunov
    Without knowing the possible history behind the question, it reads simpler. ;)



  • Ok, I found solution. I renamed class name (via Qt designer) from "MyClass" to "MyNamespace::MyClass". And now uic generates ui_*.h with required namespace. According changelog this feature was added in Qt 4.1, but still undocumented. Should I create bugreport?


  • Moderators

    @trialuser

    IMHO it is a good idea to check for and write, if required, a bug report on JIRA

    Place a link here for others to find it more easily and vote for its importance.

    You can also write a short guide of your solution on wiki.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.