[Interest] [interest] UITools - how to modify the GUI?

Tamás Nagy tamas.nagy.001 at gmail.com
Mon Apr 13 17:25:21 CEST 2015


Hi,

It was almost impossible, but it does not load the UI file:

GuiParser::GuiParser(QTreeWidget *tree)
{
    treeWidget = tree;

    QUiLoader uiLoader;
    QFile file("mainwindow.ui");   // I also copied file to C: root
and wrote fix path here
    // I also wrote here a file.open, but it does not help to change
it from unknown error to a better one
    QMessageBox msgBox0;
    msgBox0.setText( file.errorString() );  // gives UNKNOWN ERROR
    msgBox0.exec();

    ui = uiLoader.load(&file);

    QMessageBox msgBox;
    msgBox.setText( uiLoader.errorString() );  // An error occured
when reading the UI file at line 1, column 0. Premature end of
document.
    msgBox.exec();

    currentButton = NULL;
    currentLabel = NULL;
}


Tamas

2015-04-13 13:51 GMT+02:00 Tamás Nagy <tamas.nagy.001 at gmail.com>:
> Hallo,
>
> I tried to access it through TabWidget, as written in a forum as
> suggestion, but the problem is,
> that it does not find the TabWidget at all. It returns always 0 for tabwidget.
>
>  <widget class="QWidget" name="centralWidget">
>    <widget class="QTabWidget" name="TabWidget">
>     <property name="geometry">
>      <rect>
>       <x>0</x>
>       <y>40</y>
>       <width>1024</width>
>       <height>768</height>
>      </rect>
>     </property>
>     <property name="currentIndex">
>      <number>0</number>
>     </property>
>     <widget class="QWidget" name="tab">
>      <attribute name="title">
>       <string>Betriebsmenu</string>
>      </attribute>
>
> -------------------------------------------------------------------------
>
> QTabWidget * tabwidget = ui->findChild<QTabWidget*>("TabWidget",
> Qt::FindChildrenRecursively);    // ALWAYS NULL ???
>    if(tabwidget)
>    if(tabwidget->currentWidget()) {
>        QWidget * tab = tabwidget->currentWidget();
>
>        if(tab) {
>            QTextEdit * textedit2 =
> tabwidget->currentWidget()->findChild<QTextEdit*>("textEdit",
> Qt::FindChildrenRecursively);
>
>            if(textedit2) {
>                textedit2->setText("TEST writing...\n");
>                textedit2->update();
>
>                ui->update();
>            }
>
>            QString name = "textEdit_2";
>            if(tab->findChild<QTextEdit*>(name, Qt::FindChildrenRecursively))
>            {
>
>                QTextEdit * textedit =
> tabwidget->currentWidget()->findChild<QTextEdit*>(name,
> Qt::FindChildrenRecursively);
>
>                if(textedit)
>                    textedit->append("TEST writing...\n");
>            }
>
> Tamas
>
> 2015-04-13 10:06 GMT+02:00 Tamás Nagy <tamas.nagy.001 at gmail.com>:
>> Hi,
>>
>> How can be path bad? textEdit is in the centralWidget.
>> I can access it from the "ui", but not from the loaded "ui",
>> that is loaded with UILoader. I tried to call refresh() on it.
>> I can find and access any other GUI elements with
>> UILoader, but I cannot modify them. What can be wrong?
>>
>>  <widget class="QTextEdit" name="textEdit">
>>       <property name="geometry">
>>        <rect>
>>         <x>10</x>
>>         <y>400</y>
>>         <width>791</width>
>>         <height>141</height>
>>        </rect>
>>       </property>
>>       <property name="accessibleName">
>>        <string notr="true"/>
>>       </property>
>>      </widget>
>>     </widget>
>>
>>  QString name = "textEdit";
>>            if(ui->findChild<QTextEdit*>(name, Qt::FindChildrenRecursively))
>>            {
>>
>>                 QTextEdit * textedit = ui->findChild<QTextEdit*>(name,
>> Qt::FindChildrenRecursively);
>>
>>                 if(textedit)
>>                     textedit->append("TEST writing...\n");
>>            }
>>
>> Tamas
>>
>>
>> 2015-04-10 16:56 GMT+02:00 Alejandro Exojo <suy at badopi.org>:
>>> El Friday 10 April 2015, Tamás Nagy escribió:
>>>> // it always returns 0, no idea why. I have a textEdit with this name:
>>>> textEdit. QTextEdit * textedit2 = ui->findChild<QTextEdit*>("textEdit",
>>>
>>> Try:  ui->dumpObjectTree()  to see what was actually loaded as children of
>>> that object, just in case there is some typo in the object name.
>>>
>>> Otherwise, try to read the file yourself (just to print to the output the
>>> contents, to prove is readable). It could be a simple path name error.
>>>
>>> --
>>> Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
>>> http://barnacity.net/ | http://disperso.net
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list