nodeeditor
nodeeditor copied to clipboard
embeddedWidget -> QComboBox click can not pop up the drop-down item
QWidget* SourceFloatNode::embeddedWidget() { QComboBox* comboBox = new QComboBox(); comboBox->addItems({"Option 1", "Option 2", "Option 3"});
return comboBox;
}
QComboBox click can not pop up the drop-down item
Try putting it in wrapper widget:
QWidget* SourceFloatNode::embeddedWidget(){
QWidget *base = new QWidget();
base->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
QComboBox* comboBox = new QComboBox();
comboBox->addItems({"Option 1", "Option 2", "Option 3"});
base->layout()->addWidget(comboBox);
return base;
}
I tried your code. It has a "big" side effect:
But if you instantiate the widget only once, it works well. Thanks.
class NumberSourceDataModel : public NodeDelegateModel
{
......
private:
QWidget *_base;
};
QWidget *NumberSourceDataModel::embeddedWidget()
{
if (!_base) {
_base = new QWidget();
QHBoxLayout *la = new QHBoxLayout(_base);
_base->setLayout(la);
QComboBox *comboBox = new QComboBox();
comboBox->addItems({"Option 1", "Option 2", "Option 3"});
la->addWidget(comboBox);
}
return _base;
}
Another possibility is a bug in Qt 6.7.
See https://forum.qt.io/topic/158614/qcombobox-fails-to-display-dropdown-when-placed-in-qgraphicsview-via-qgraphicsproxywidget/2
Setting QApplication::setStyle(QStyleFactory::create("windowsvista")); fixed it for me. But of course, it affects the style...
This issue does not recur in qt 6.10.0.
https://github.com/user-attachments/assets/e4809502-8293-4e4c-8d51-56f1adfe5fdd