[Solved] Popup of QComboBox showing and immediately hiding



  • Hello!

    I derived QComboBox and reimplement showPopup() function where I'm dynamically filling model before call parent QComboBox::showPopup() like this:

    @void MyComboBox::showPopup()
    {
    fillModel();
    QComboBox::showPopup();
    }@

    But, if fillModel() calling for a long time (above 1-2 seconds), popup is showing and immediately hiding. What is reason of it and how can I change this behaviour?


  • Lifetime Qt Champion

    Hi,

    How are you filling the model ? And why do it at that time ?



  • There is table and MyComboBox is a filter for every column in table header which contains unique values of columns. These values retrieving from database and filling all filters immediately is not optimal if table has many columns and rows. Function fillModel() is trivial:

    @
    void MyComboBox::fillModel()
    {
    clear();
    QStringList values = fooBar();
    addItems(values);
    }
    @



  • Solution which helped me:

    @
    void MyComboBox::showPopup()
    {
    fillModel();
    QApplication::processEvents();
    QComboBox::showPopup();
    }
    @


  • Lifetime Qt Champion

    So fooBar() accesses the database before to populate combo box model ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.