PDA

View Full Version : QtTreePropertyBrowser enabled but not editable



west
2nd October 2014, 10:14
I have the QtTreePropertyBrowser whose items mustn't be editable but user wants to be able to scroll and expand root items. Is it possible to reach this? Method setEnabled isn't the solution because it freezes the whole widget.

west
8th October 2014, 19:18
Hi guys, what do you think about my solution? :)



void Widget::setBrowserEditable(bool editable)
{
QList<QWidget *> widgets = m_browser->findChildren<QWidget *>();
foreach(QWidget *wgt, widgets)
{
if ( wgt->inherits("QScrollBar") || wgt->inherits("QtPropertyEditorView") )
{
continue;
}

wgt->setEnabled(editable);
}
}

wysota
8th October 2014, 20:01
Can't you simply make the properties not editable?

west
8th October 2014, 20:22
Unfortunately some of displayed properties are read only so I would have to remember which properties were not editable.

wysota
8th October 2014, 20:34
So do that.

aliks-os
29th January 2016, 18:34
another way to make


void MainWindow::setPropTreeElemReadOnly(bool mode) {
foreach(QtProperty *property, propertyTree->properties()) {
property->setEnabled(mode);
qDebug()<<property->propertyName();
if (property->propertyName() == "StateEnable") {
property->setEnabled(true);
}
}
}