Reimplementation of QComboBox showPopup() works only once
-
We are trying to reimplement QComboBox::showPopup(). The code below sets selected index and hidePopup is called(). It works only once per combobox instance. Consecutive clicks on the same combobox do not invoke showPopup(). It seems that call to hidePopup() has no effect and internal state of combobox is not reset...
@
#include <QWebView>
#include <QApplication>
#include <QComboBox>
#include <QDebug>void QComboBox::showPopup()
{
qDebug()<<"QComboBox::showPopup()";
emit activated(3);
hidePopup();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView webView;
webView.setGeometry(0,0,800,600);
webView.load(QUrl("http://www.facebook.com"));
webView.show();return a.exec();
}
@
[andreyc EDIT: added @ around the code] -
You need to derive your own class from QComboBox if you need to re-implement its member functions.
In your example QComboBox::showPopup() is never called.
-
Thanks for your replying.
My showPopup() is called. Because the message, "QComboBox::showPopup() ", is shown.What I want to do is to create a widget in the reimplemented showPopup().
-
Frankly speaking I don't see from your example how QComboBox::showPopup() can be called.
Did you modify QComboBox class?[quote]What I want to do is to create a widget in the reimplemented showPopup().[/quote]You need to define a widget class manually or in designer and then create it in the function.
-
Linux does allow us to override these two methods (showPopup, hidePopup) directly.
Could you try the code I posted.