Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt designer reading xml(.ui) file implementation
Forum Updated to NodeBB v4.3 + New Features

Qt designer reading xml(.ui) file implementation

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Sam
    wrote on 6 Sept 2012, 09:09 last edited by
    #1

    Hi,

    I have a requirement where i need to read an xml file which specifies the layout and position of the widgets in a Form/QMainWindow.
    Since Qt designer also works in the same way i.e reading from the xml structure in .ui file and loading it to the frame/widget.

    Where can i find the above implementation I checked "QUiLoader.cpp":http://qt.gitorious.org/qt/qttools/blobs/ad9b37a706567147b78d22d0de4a016b6c5af9b3/src/designer/src/uitools/quiloader.cpp. but could not understand much.

    Thanks in advance.

    Note: With my own implementation I am able to read the xml file and load the widget to the form for single Layouts like QGridLayout , QFormLayout etc. I need an idea for the implementation of multiple layouts like a QGridLayout has a QHboxLayout etc.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 6 Sept 2012, 09:37 last edited by
      #2

      I don't know what your real question is here. You could implement your own scheme of course, but why would you? [[doc:QUiLoader]] can do it for you, based on standard .ui files that you already own a complete editor for: QtDesigner/QtCreator. It seems to me that it is harder to create your own system, than to spend the effort to learn about using QUiLoader by reading its docs and doing some experiments.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on 6 Sept 2012, 11:29 last edited by
        #3

        Thanks Andre,

        Here the xml file consists of my own custom widgets. for eg:-

        sample.xml

        @<?xml version='1.0' encoding='UTF-8'?>
        <Interface type="ConfigFrame">
        <Attributes>
        <Attribute name="WindowsTitle" value="Some Values For Parent Widget"/>
        <Attribute name="HeaderTitle" value="Dummy Screen"/>
        </Attributes>
        <Layout type="Grid" name="mainLayout">
        <Component type="Frame" name="frameTop">
        <Position row="0" col="0" rowSpan="1" colSpan="3"/>
        <Layout type="Grid" name ="upperLayout">
        <Layout type="Horizontal" name="hBox" stretch="80">
        <Position row="0" col="2" rowSpan="1" colSpan="1"/>
        <Component type="Label" name="labelUser">
        <Text alignment="TopCenter" textNo="100">User# </Text>
        </Component>
        <Component type="LineEdit" name="lineEditUser">
        <Text> 1 </Text>
        </Component>
        </Layout>
        <Component type ="Label" name="labelFullName" >
        <Position row="1" col="1" rowSpan="1" colSpan="1" />
        <Text alignment="TopCenter" textNo="101"> User Login </Text>
        </Component>
        <Component type ="LineEdit" name="lineEditFullName" >
        <Position row="1" col="2" rowSpan="1" colSpan="2" />
        <Text> Test </Text>
        </Component>
        </Layout>
        </Component>
        </Layout>
        </Interface>@

        So the requirement is that at the runtime I am going to read the xml file and add the same to a Form. For the custom widget there are other attributes/properties as well. So for the implementation I was thinking to get an idea how the QUiLoader class works ?

        Thanks again.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 6 Sept 2012, 12:20 last edited by
          #4

          You're still not asking a question.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on 6 Sept 2012, 13:01 last edited by
            #5

            Sorry I might not be clear with my question. I want to know how the QUiLoader reads the xml file(.ui) and loads the widgets to the form i.e I want to generate a panel/frame thats contain the widgets specified in the xml file at the particular position based on the layouts. Then this panel/frame is added to the main module/application/frame.

            The steps that i follow are.

            1. Reading the xml file using QXmlStreamReader.
            2. Storing the components/widgets to a container.
            3. Storing the attributes of the components/widget to another container.
            4. Then based on the layout , adding the component/widgets to the frame.

            Problem is to handle multiple layouts. Also i want to know if this is the correct approach or not ?

            1 Reply Last reply
            0

            1/5

            6 Sept 2012, 09:09

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved