Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved UI loaded with QUILoader, cannot stretch properly and clears when pressing escape

    General and Desktop
    3
    8
    1295
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      ESP123 last edited by

      We are using QT 5.6, and using QUILoader to load ui files at runtime, from within qt resource files ... this all works great and there is no issue loading the ui or operation, connecting buttons and getting field values, etc ... what i do i create a top level QDialog, grab its layout, and add the loaded widget to the layout .. the issue is that (1) i want all the children to stretch nicely as the top level dialog is scaled, (how can i tell the top level all should stretch horizonally for example?) and (2) when i press escape the contents of my top level dialog are cleared, so the entire ui loaded from xml dissapears ... no idea why ... any help appreciated

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        Two things based on your description.

        1. Did you add the stretch factor for UILoaded widget when adding into layout ?
        2. Have you set the stretch factor for widgets present in the UILoaded widget ?
        3. When you are clearing the dialog, what is the code you ? Are you deleting the top level widget ? I suspect so. When you delete the widgets all the children are also deleted.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        E 1 Reply Last reply Reply Quote 1
        • E
          ESP123 @dheerendra last edited by

          @dheerendra

          1. i tried all sort of combinations of setting stretch factor, none seemed to work .. what is the recommended way? do i need to set on all objects?
          2. no i did not but i did try programmatically
          3. this happens automatically somehow, this is not programmed in, which is why i am asking how/why it happens?
          E 1 Reply Last reply Reply Quote 0
          • E
            ESP123 @ESP123 last edited by

            @ESP123 to clarify on #3, i open and create a dialog, then i add the loaded widget onto it .. when i press escape, the added widget dissapears, the parent widget is still open it is just empty

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Hi and welcome to devnet,

              Please show us the code you use, that will make things easier.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 1 Reply Last reply Reply Quote 0
              • E
                ESP123 @SGaist last edited by

                @SGaist

                after loading widget using quiloader, then i instantiate a child of QDialog, where in the constructor i use:

                QLayout *layout = this->layout();
                QWidget *myWidget = (loaded widget);
                myWidget->show();
                layout->addWidget(myWidget);
                this->show();
                this->activateWindow();
                this->raise();
                
                1 Reply Last reply Reply Quote 0
                • dheerendra
                  dheerendra Qt Champions 2022 last edited by

                  This code piece does not have any issue. I suggest you prepare a complete sample which is giving a problem.

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply Reply Quote 1
                  • E
                    ESP123 last edited by

                    I figured it out, i needed an event filter to capture the child events, so when escape is pressed, it did not go blank, since qt dialog wants to close .. but the parent was still open .. works now thank you

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post