nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

embeddedWidget -> QComboBox click can not pop up the drop-down item

Open qq978358810 opened this issue 11 months ago • 1 comments

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

qq978358810 avatar Dec 13 '24 13:12 qq978358810

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;
}

vlad-mod avatar Dec 17 '24 09:12 vlad-mod

I tried your code. It has a "big" side effect:

Image

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;
}
Image

bansan85 avatar Oct 07 '25 14:10 bansan85

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...

bansan85 avatar Oct 08 '25 10:10 bansan85

This issue does not recur in qt 6.10.0.

https://github.com/user-attachments/assets/e4809502-8293-4e4c-8d51-56f1adfe5fdd

cxxamz avatar Oct 18 '25 14:10 cxxamz