Tips and tricks for 'backtracing' UI elements into the code.



  • Hi,

    OK making a UI with Qt is not a problem, but for an existing codebase and tracing what goes where is what I'm having difficulty with.

    Certainly this is not a knock against Qt. All UI software is kind of like this. So for this case, where an existing codebase uses Qt and localization, how do I figure out, from looking at something like a QDialog, where the associated logic will be? I don't expect it to be in plain sight and I don't know what files/constructs/docs to look for.

    I see the text specified in .ini files being used in the QDialog but I am having trouble tracing the string's name to a form file or code.

    Thanks


  • Qt Champions 2017

    Hi, its not 100% sure the dialog has a UI file.
    It is easy to make without.
    You can check the constructor of the Dialog (in cpp)
    if It has
    ui->setupUi(this);
    there is a UI file.

    Also if u stand in the Dialogs h file, you can right click functions and variables and
    use the "Find Usages" too see where its being used.
    That is what I use to "discover" the structure of a new project.

    Also "follow symbol under cursor" is good for the other way, as in
    where does this live.

    If you are after localization, you would go and look for QTranslator using the super find function.
    Note, if they use a ini file, it might not be the normal way.



  • This is too dependent of the project. I found what I needed. It's just buried by lots of fuction calls and won't have the name that you expect.


  • Qt Champions 2017

    @osssome
    super.
    well people name things very differently sometimes.



  • @mrjj

    I didn't get a chance to use your info yet. I will dig around some more using your advice. Thanks!



  • @mrjj Yes they are using .ini everywhere. :'(


  • Qt Champions 2017

    @osssome
    Well sometimes running the program in debug mode and single step around also helps to see
    what calls what and when.

    Are you trying to add new translation to it?



  • I'm not. But your advice helped me. Thanks!


Log in to reply
 

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