"QComboBox Pop-up" expanding and QtWebkit

Viewed 2577

In Firefox/Chrome/InternetExplorer/Safari/Opera pop-ups from the combobox expand as the content, see Firefox picture:

Firefox combobox

QComboBox pop-up does not expand the content. Pop-ups are limited by the size of QComboBox, see QWebView picture:

Qt and QtWebkit combobox

So I implemented the QComboBox::showPopup:

void newQComboBox::showPopup() {
    int width = this->width();
    this->view()->setTextElideMode( Qt::ElideNone );

    const int iconSize = this->iconSize().width();
    const QFontMetrics fontMetrics = this->fontMetrics();
    const int j = this->count();

    for( int i=0; i < j; ++i ) {
        const int textWidth = fontMetrics.width( this->itemText(i) + "WWW" );
        if (this->itemIcon(i).isNull()) {
            width = qMax(width, textWidth);
        } else {
            width = qMax(width, textWidth + iconSize);
        }
    }

    QStyleOptionComboBox opt;
    this->initStyleOption(&opt);
    QSize size(width, 0);
    size = this->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, size, this);

    this->view()->setFixedWidth( width );

    QComboBox::showPopup();
}

Is there any way to modify (reimplement) the QComboBox::showPopup of QWebViews (QtWebkit)?

Qt-BUG (suggestion): https://bugreports.qt.io/browse/QTBUG-35771

2 Answers
Related