Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Popup of QComboBox showing and immediately hiding
Forum Updated to NodeBB v4.3 + New Features

[Solved] Popup of QComboBox showing and immediately hiding

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 995 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blacky
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blacky
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blacky
          wrote on last edited by
          #4

          Solution which helped me:

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

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved