PDA

View Full Version : Designer plugin widget property not recognized



janus
11th April 2009, 13:17
Hi,

I crated a simple designerplugin. It is a subclassed QLineEdit with a few additional properties:


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:
LineEdit(QWidget *parent = 0);

QString tableName() const;
void setTableName(const QString &tableName);
QString columnName() const;
void setColumnName(const QString &columnName);

private:
QString m_tableName;
QString m_columnName;

};


Designer loads the plugin, but I do not get the no_translation option in the property editor. I tried to set it in domXML():


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?

wysota
11th April 2009, 13:37
What property are we talking about? I can only see "tableName" and "columnName" properties declared.

janus
11th April 2009, 13:44
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):


if (QDesignerFormWindowInterface *formWindow
= QDesignerFormWindowInterface::findFormWindow(lineE dit)) {
formWindow->cursor()->setWidgetProperty(lineEdit, "tableName", ui.tableComboBox->currentText());
formWindow->cursor()->setWidgetProperty(lineEdit, "columnName", ui.columnComboBox->currentText());
}

wysota
11th April 2009, 15:21
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.

janus
11th April 2009, 19:28
Setting "notr" with my tastextension works now if I use


lineEdit->setTableName(ui.tableComboBox->currentText());

instead of


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.

wysota
11th April 2009, 20:23
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.

janus
12th April 2009, 08:09
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.

wysota
14th April 2009, 21:26
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?