Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Editing ui C++ code ?



  • OK, I am having another senior moment , so be reasonable....
    I am trying to modify btchat example.
    From what I can tell it has been build without benefit of QtDesigner.

    I can open chat.ui in QtDesigner and edit it to my hart's desire.
    I actually have no idea where did "chat.ui" came from if the ui is build in C++ code.

    BUT my btchat project ignores all 'chat.ui" changes done in QtDesigner.

    I found a link which supposedly address this but it is very old and inaccessible.

    Basically - can I edit "ui" anything using both QtCreator code and QtDesigner GUI ?

    EDITED
    I found this
    https://doc.qt.io/archives/2.3/designer/chap2_2.html

    It sort of explains how "filename.ui" get created so what is left is how to make it work the opposite direction - from "filename.ui" back to "filename.cpp".



  • @AnneRanch
    refer to the following link
    https://doc.qt.io/qt-5/designer-using-a-ui-file.html

    User Interface Compiler (uic) reads an XML format user interface definition (.ui) file as generated by Qt Designer and creates a corresponding C++ header file.

    https://doc.qt.io/qt-5/uic.html



  • Been there already. It explains how "filename.ui" gets created.
    It does not help to "work from QtDesigner to QtCreator".
    I actually verified that QtDesigner can pass code "go to slot" using existing button. Works fine.
    But I cannot add any new widget to chat.ui form to be passed to chat.cpp code..



  • @AnneRanch

    BUT my btchat project ignores all 'chat.ui" changes done in QtDesigner.
    

    are you making changes for .ui by seperately launching QtDesigner?
    QtDesigner is integrated to QtCreator.

    What changes it's not reflecting?
    https://forum.qt.io/topic/124803/title-bar-messing-dialog-layout



  • @AnneRanch said in Editing ui C++ code ?:

    can open chat.ui in QtDesigner and edit it to my hart's desire.
    I actually have no idea where did "chat.ui" came from if the ui is build in C++ code.
    BUT my btchat project ignores all 'chat.ui" changes done in QtDesigner.

    can open chat.ui in QtDesigner - FROM qtCreator - and edit it to my hart's desire.
    BUT my btchat project ignores all 'chat.ui" changes done in QtDesigner.

    Please ignore this post .
    It is easier to copy and paste the working (example) code using standard widget form with normal relations between QtCreator and QtDesigner - none of this half baked and undocumented "build with code GUI " , thus bypassing the QtDesigner , example(s). (I guess expecting updated example using QtDesigner is foolish)

    "search and replace " works so renaming the original code would be a snap.

    CASE CLOSED ?


  • Moderators

    @AnneRanch Most of the time I have a hard time deciphering what you're actually asking/wanting to do, so I'm not commenting.

    but regarding this:

    BUT my btchat project ignores all 'chat.ui" changes done in QtDesigner

    what version of QtCreator do you work with? the latest one (4.14.2) ? Because I remember some older versions that had synchronization issues.

    That said, open preferences/settings, go to build&run check the checkbox next to "run qmake on every build"

    It will increase your build time, but your issues should lessen/disappear.

    f3800ae3-c738-48bd-93a5-6bd5282b97c2-image.png

    I actually verified that QtDesigner can pass code "go to slot" using existing button. Works fine.

    I highly discourage the use of the "Connect Slot By Name" feature. It is prone to breaking with the smallest of changes in source or ui code



  • Hope this will demonstrate the problem.
    Unfortunately I have "breal the layout" and it really doe sno match.

    BUT
    the "chat.ui" has "tab" widget and it does not show during run.
    The "chat.ui" and whatever is used during "run" do not match.

    28d036ea-fd47-4a5c-8b02-2baac702941c-image.png

    804723c9-df48-4402-9a06-21cc78514f3b-image.png

    PS I have used "go to slot" to verify that the run is actually using the "chat.ui"
    and not some other "ui" file.

    I am going to try to find what is the code difference between "btchat" code created form and when I use "QDesigner form class" .

    This is not first time I have been told to check version , however I still believe that the sample "btchat" "problem" is it was (obviously) not build using QtDEsigner and it is not that clear HOW different piece parts of the "widget" works.

    FRom get go I have struggled with C code , XML and "ui" .
    I wish some documentation would say how all these parts interact.

    For example ".ui file is build from C) source via XML ' does no really say much how it is used in C code flow.

    However , at this point I am going to build my own "chat" using "QDesigner form class" - it is proven to work as expected.

    I forgot - yes - I have "always build qmake " optioned.


Log in to reply