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. Reimplementation of QComboBox showPopup() works only once
Forum Updated to NodeBB v4.3 + New Features

Reimplementation of QComboBox showPopup() works only once

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.7k 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.
  • Y Offline
    Y Offline
    yao.wanhui
    wrote on last edited by
    #1

    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(&#41;;
    

    }
    @
    [andreyc EDIT: added @ around the code]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yao.wanhui
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yao.wanhui
            wrote on last edited by
            #5

            Linux does allow us to override these two methods (showPopup, hidePopup) directly.
            Could you try the code I posted.

            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