Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. Loading ui at runtime
Forum Updated to NodeBB v4.3 + New Features

Loading ui at runtime

Scheduled Pinned Locked Moved India
19 Posts 2 Posters 11.5k 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.
  • H Offline
    H Offline
    hema
    wrote on last edited by
    #5

    selectiondialog.ui
    file exists in the forms

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hema
      wrote on last edited by
      #6

      K , but file.open is returing true

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #7

        Ok then, did you create the ui file yourself ?

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

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hema
          wrote on last edited by
          #8

          sorry for a long delay ,
          this ui is created by myself
          I am calling this ui in one function funcn()
          funcn()
          {
          QFile file(":/forms/selectiondialog.ui");
          QWidget *selectionWidget = this->loadUiFile(file);
          }

          QWidget* OptimaRTools::loadUiFile(QFile& file1)
          {

          QUiLoader loader;
           QFile file(":/forms/selectiondialog.ui");
          file.open(QFile::ReadOnly);
          file.errorString();
          QWidget *formWidget = loader.load(&file);
          file.close();
          

          return formWidget;
          }

          and the ui file is

          <?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
          <class>Dialog</class>
          <widget class="QDialog" name="Dialog">
          <property name="geometry">
          <rect>
          <x>0</x>
          <y>0</y>
          <width>322</width>
          <height>189</height>
          </rect>
          </property>
          <property name="windowTitle">
          <string>Dialog</string>
          </property>
          <layout class="QGridLayout" name="gridLayout_2">
          <item row="0" column="0" colspan="3">
          <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
          <widget class="QLabel" name="lbl_First">
          <property name="text">
          <string/>
          </property>
          </widget>
          </item>
          <item row="0" column="1">
          <widget class="QLabel" name="lbl_Second">
          <property name="text">
          <string/>
          </property>
          </widget>
          </item>
          <item row="1" column="0">
          <widget class="QListWidget" name="listWidget_Initial"/>
          </item>
          <item row="1" column="1">
          <widget class="QListWidget" name="listWidget_Final"/>
          </item>
          </layout>
          </item>
          <item row="1" column="0">
          <spacer name="horizontalSpacer_2">
          <property name="orientation">
          <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
          <size>
          <width>65</width>
          <height>20</height>
          </size>
          </property>
          </spacer>
          </item>
          <item row="1" column="1">
          <widget class="QDialogButtonBox" name="buttonBox">
          <property name="orientation">
          <enum>Qt::Horizontal</enum>
          </property>
          <property name="standardButtons">
          <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
          </property>
          </widget>
          </item>
          <item row="1" column="2">
          <spacer name="horizontalSpacer">
          <property name="orientation">
          <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
          <size>
          <width>65</width>
          <height>20</height>
          </size>
          </property>
          </spacer>
          </item>
          </layout>
          </widget>
          <resources/>
          <connections>
          <connection>
          <sender>buttonBox</sender>
          <signal>accepted()</signal>
          <receiver>Dialog</receiver>
          <slot>accept()</slot>
          <hints>
          <hint type="sourcelabel">
          <x>248</x>
          <y>254</y>
          </hint>
          <hint type="destinationlabel">
          <x>157</x>
          <y>274</y>
          </hint>
          </hints>
          </connection>
          <connection>
          <sender>buttonBox</sender>
          <signal>rejected()</signal>
          <receiver>Dialog</receiver>
          <slot>reject()</slot>
          <hints>
          <hint type="sourcelabel">
          <x>316</x>
          <y>260</y>
          </hint>
          <hint type="destinationlabel">
          <x>286</x>
          <y>274</y>
          </hint>
          </hints>"
          </connection>
          </connections>
          </ui>

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #9

            Please use coding tags

            What do you mean by yourself ? Using the designer integrated with QtCreator ?

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

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hema
              wrote on last edited by
              #10

              ui is created using Qt designer form

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hema
                wrote on last edited by
                #11

                @<?xml version="1.0" encoding="UTF-8"?>
                <ui version="4.0">
                <class>Dialog</class>
                <widget class="QDialog" name="Dialog">
                <property name="geometry">
                <rect>
                <x>0</x>
                <y>0</y>
                <width>322</width>
                <height>221</height>
                </rect>
                </property>
                <property name="windowTitle">
                <string>Dialog</string>
                </property>
                <widget class="QDialogButtonBox" name="buttonBox">
                <property name="geometry">
                <rect>
                <x>65</x>
                <y>187</y>
                <width>181</width>
                <height>32</height>
                </rect>
                </property>
                <property name="orientation">
                <enum>Qt::Horizontal</enum>
                </property>
                <property name="standardButtons">
                <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
                </property>
                </widget>
                <widget class="QWidget" name="layoutWidget">
                <property name="geometry">
                <rect>
                <x>10</x>
                <y>10</y>
                <width>301</width>
                <height>171</height>
                </rect>
                </property>
                <layout class="QGridLayout" name="gridLayout">
                <item row="0" column="0">
                <widget class="QLabel" name="lbl_First">
                <property name="text">
                <string/>
                </property>
                </widget>
                </item>
                <item row="0" column="1">
                <widget class="QLabel" name="lbl_Second">
                <property name="text">
                <string/>
                </property>
                </widget>
                </item>
                <item row="1" column="0">
                <widget class="QListWidget" name="listWidget_Initial"/>
                </item>
                <item row="1" column="1">
                <widget class="QListWidget" name="listWidget_Final"/>
                </item>
                </layout>
                </widget>
                </widget>
                <resources/>
                <connections>
                <connection>
                <sender>buttonBox</sender>
                <signal>accepted()</signal>
                <receiver>Dialog</receiver>
                <slot>accept()</slot>
                <hints>
                <hint type="sourcelabel">
                <x>248</x>
                <y>254</y>
                </hint>
                <hint type="destinationlabel">
                <x>157</x>
                <y>274</y>
                </hint>
                </hints>
                </connection>
                <connection>
                <sender>buttonBox</sender>
                <signal>rejected()</signal>
                <receiver>Dialog</receiver>
                <slot>reject()</slot>
                <hints>
                <hint type="sourcelabel">
                <x>316</x>
                <y>260</y>
                </hint>
                <hint type="destinationlabel">
                <x>286</x>
                <y>274</y>
                </hint>
                </hints>
                </connection>
                </connections>
                </ui>
                @

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  What does print:

                  @qDebug() << file.readAll();@

                  ?

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

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hema
                    wrote on last edited by
                    #13

                    @"<?xml version="1.0" encoding="UTF-8"?>
                    <ui version="4.0">
                    <class>Dialog</class>
                    <widget class="QDialog" name="Dialog">
                    <property name="geometry">
                    <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>322</width>
                    <height>189</height>
                    </rect>
                    </property>
                    <property name="windowTitle">
                    <string>Dialog</string>
                    </property>
                    <layout class="QGridLayout" name="gridLayout_2">
                    <item row="0" column="0" colspan="3">
                    <layout class="QGridLayout" name="gridLayout">
                    <item row="0" column="0">
                    <widget class="QLabel" name="lbl_First">
                    <property name="text">
                    <string/>
                    </property>
                    </widget>
                    </item>
                    <item row="0" column="1">
                    <widget class="QLabel" name="lbl_Second">
                    <property name="text">
                    <string/>
                    </property>
                    </widget>
                    </item>
                    <item row="1" column="0">
                    <widget class="QListWidget" name="listWidget_Initial"/>
                    </item>
                    <item row="1" column="1">
                    <widget class="QListWidget" name="listWidget_Final"/>
                    </item>
                    </layout>
                    </item>
                    <item row="1" column="0">
                    <spacer name="horizontalSpacer_2">
                    <property name="orientation">
                    <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                    <size>
                    <width>65</width>
                    <height>20</height>
                    </size>
                    </property>
                    </spacer>
                    </item>
                    <item row="1" column="1">
                    <widget class="QDialogButtonBox" name="buttonBox">
                    <property name="orientation">
                    <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="standardButtons">
                    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
                    </property>
                    </widget>
                    </item>
                    <item row="1" column="2">
                    <spacer name="horizontalSpacer">
                    <property name="orientation">
                    <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                    <size>
                    <width>65</width>
                    <height>20</height>
                    </size>
                    </property>
                    </spacer>
                    </item>
                    </layout>
                    </widget>
                    <resources/>
                    <connections>
                    <connection>
                    <sender>buttonBox</sender>
                    <signal>accepted()</signal>
                    <receiver>Dialog</receiver>
                    <slot>accept()</slot>
                    <hints>
                    <hint type="sourcelabel">
                    <x>248</x>
                    <y>254</y>
                    </hint>
                    <hint type="destinationlabel">
                    <x>157</x>
                    <y>274</y>
                    </hint>
                    </hints>
                    </connection>
                    <connection>
                    <sender>buttonBox</sender>
                    <signal>rejected()</signal>
                    <receiver>Dialog</receiver>
                    <slot>reject()</slot>
                    <hints>
                    <hint type="sourcelabel">
                    <x>316</x>
                    <y>260</y>
                    </hint>
                    <hint type="destinationlabel">
                    <x>286</x>
                    <y>274</y>
                    </hint>
                    </hints>
                    </connection>
                    </connections>
                    </ui>
                    "
                    Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document.
                    "Phonon::SeekSlider" @

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      Really strange...

                      Could you try to run the Calculator builder example ? To see if it also has the same problem

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

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hema
                        wrote on last edited by
                        #15

                        I have tried calculator builder and text finder examples they are working fine

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #16

                          Then copy the ui file from the example in your project and try to load to see if it works also there

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

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            hema
                            wrote on last edited by
                            #17

                            @"<ui version="4.0" >
                            <author></author>
                            <comment></comment>
                            <exportmacro></exportmacro>
                            <class>CalculatorForm</class>
                            <widget class="QWidget" name="CalculatorForm" >
                            <property name="objectName" >
                            <string notr="true" >CalculatorForm</string>
                            </property>
                            <property name="geometry" >
                            <rect>
                            <x>0</x>
                            <y>0</y>
                            <width>276</width>
                            <height>98</height>
                            </rect>
                            </property>
                            <property name="sizePolicy" >
                            <sizepolicy>
                            <hsizetype>5</hsizetype>
                            <vsizetype>5</vsizetype>
                            <horstretch>0</horstretch>
                            <verstretch>0</verstretch>
                            </sizepolicy>
                            </property>
                            <property name="windowTitle" >
                            <string>Calculator Builder</string>
                            </property>
                            <layout class="QGridLayout" >
                            <property name="objectName" >
                            <string notr="true" />
                            </property>
                            <property name="margin" >
                            <number>9</number>
                            </property>
                            <property name="spacing" >
                            <number>6</number>
                            </property>
                            <item row="0" column="0" >
                            <layout class="QHBoxLayout" >
                            <property name="objectName" >
                            <string notr="true" />
                            </property>
                            <property name="margin" >
                            <number>1</number>

                            1 Reply Last reply
                            0
                            • H Offline
                              H Offline
                              hema
                              wrote on last edited by
                              #18

                              loading calculator.ui giving the same error in my application

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #19

                                Then can you post your pro file and a minimal code example that reproduce the problem ?

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

                                1 Reply Last reply
                                0

                                • Login

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