Problems in mainwindow.ui
-
Hi all,
I'm developing some custom widgets and normally they seem to work as expected. I have a problem with one of them: I have 2 very similar properties and when I save the project that uses that widget and reload it, one of this properties still has the saved value but the other lost it. I opened the mainwindow.ui and the content is similar for the 2 properties but is different if I "edit" the mainwindow.ui inside QTCreator.
In the external editor ...
(...)
<property name="tag">
<url>
<string>MyString1</string>
</url>
</property>
<property name="tagEnab">
<url>
<string>MyString2</string>
</url>
</property>
(...)Inside the QTCreator ...
(...)
<property name="tag">
<url>
</string>
</url>
</property>
<property name="tagEnab">
<url>
<string>MyString2</string>
</url>
</property>
(...)... <string>MyString1 ... has been removed !
So the second property works fine, the first one not.
If I exit from QTCreator and edit the mainwindow.ui with a text editor the file is still perfect !
Any ideas ?
Tanks in advance.
Vittorio -
Hi
Im not really sure what that could be.
Would it be possible to name the propery something other than tag and see if
its some sort of name clash.Are both tag and tagEnab declared the same way in .h `?
-
Thanks mrjj for your suggestion.
I changed the property 'tag' to 'txg', but I still have the problem.
(tag and tagEnabled are declared in the same way ...) -
Hi
Ok it was worth a shot.Would it be possible to make a smaller test project containing the custom widgets
so we can test it out our self ?I really have no idea why it would eat one property but it often helps to fiddle with the code directly.
-
Thanks again,
following your hint I reduced the custom widget at minimum (3 properties) and the problem was still there. Then I added some outputs with qDebug and I realized that my property write method (setTag, setTagEnab, ...) were called twice when I opened the form where the widget are placed. The first time before the paintEvent, the second after it. This caused me a problem so I didn't assign the 'tag' value to the corresponding private variable 'm_tag' that is returned in the 'property get' reoutine. To bypass the problem I set a variable in the painEvent to distinguish between the first and the second 'property set' call and the problem has been solved.
Just an annotation: in the setTag routine I read a file from the resources and it looks like the resources are not fully available before the paintEvent. It's just an impression: consider that I'm a newbie ... ;-)
Thanks a lot four your support !