Designer plugin widget property not recognized
Hi,
I crated a simple designerplugin. It is a subclassed QLineEdit with a few additional properties:
Code:
class QDESIGNER_WIDGET_EXPORT LineEdit
: public QLineEdit{
Q_OBJECT
Q_PROPERTY(QString tableName READ tableName WRITE setTableName
) Q_PROPERTY(QString columnName READ columnName WRITE setColumnName
)
public:
void setTableName
(const QString &tableName
);
void setColumnName
(const QString &columnName
);
private:
};
Designer loads the plugin, but I do not get the no_translation option in the property editor. I tried to set it in domXML():
Code:
QString LineEditPlugin
::domXml() const {
return "<widget class=\"LineEdit\" name=\"lineEdit\">\n"
" <property name=\"tableName\" >\n"
" <string notr=\"true\"></string>\n"
" </property>\n"
" <property name=\"columnName\" >\n"
" <string notr=\"true\"></string>\n"
" </property>\n"
"</widget>\n";
}
The "notr" is always ignored and not saved to the .ui file. Any idea why? and how i can use this feature with the new properties?
Re: Designer plugin widget property not recognized
What property are we talking about? I can only see "tableName" and "columnName" properties declared.
Re: Designer plugin widget property not recognized
yes. I dont what that these two properties to appear in linguist. Therefore I would like to set notr="true" in the .ui file. When I edit the properties in designers property editor it works properly (I get notr="true" in the ui file). But when I use my taskmenuextension the notr is removed ...
tasmenuextension dialog is setting the properties like this (which works for the property value but as I said notr is removed):
Code:
formWindow->cursor()->setWidgetProperty(lineEdit, "tableName", ui.tableComboBox->currentText());
formWindow->cursor()->setWidgetProperty(lineEdit, "columnName", ui.columnComboBox->currentText());
}
Re: Designer plugin widget property not recognized
I admit I still don't see the problem. Your task menu extension doesn't influence the way the .ui file is generated. So the real problem is you don't know how to add the notr="true" attribute to the property. And I don't think there is an easy way to do that (if at all). What you can do is to use the "comment" subproperty of textual properties to enter information for the translator - like "don't translate this". It will probably be the easiest way to do it.
Re: Designer plugin widget property not recognized
Setting "notr" with my tastextension works now if I use
Code:
lineEdit->setTableName(ui.tableComboBox->currentText());
instead of
Code:
formWindow->cursor()->setProperty("tableName", ui.tableComboBox->currentText());
I think setting "notr" in domXML is ok. The Problem left is, that the property editor needs to be updated with the new values.
But you are right :-) Actually I have no idea. It is just trial and error. All these interfaces are really difficult to understand.
Re: Designer plugin widget property not recognized
You can file a suggestion to Qt Software. They might introduce one more tag to Q_PROPERTY - like "translatable" or something like that. Or a checkbox in Designer indicating whether you want that text value to be retained regardless of language. I guess this would be the best option.
Re: Designer plugin widget property not recognized
Hi,
this suggestion is like "carrying owls to athens" i suppose :) Because in Qt 4.5 Designer there is such a feature (checkable Option translate or not). But It is not displayed with my added properties. If I add a dynamic property the checkbox is shown. Guess there is something wrong with my plugin widgets. But a possibility to add this option in Q_PROPERTY is a good idea. And there could be a few more examples covering the other designer interfaces.
Re: Designer plugin widget property not recognized
The mechanism works fine for QString fields in my custom widgets without any extra effort. Could you prepare a minimal compilable example of a plugin reproducing the problem?