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. Customizing QComboBox
Forum Updated to NodeBB v4.3 + New Features

Customizing QComboBox

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 3 Posters 4.5k Views 2 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.
  • Ivan NetskinI Ivan Netskin

    @raven-worx
    Thanks, yes this helps, but side effect is that expand/collapse button stops working. i'll go to browse the qt's sources to find out the reason.

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #6

    @Ivan-Netskin
    Hi
    bool QComboBoxPrivateContainer::eventFilter
    is stealing the mouseReleased from you.
    ( i think :)

    Ivan NetskinI 1 Reply Last reply
    0
    • mrjjM mrjj

      @Ivan-Netskin
      Hi
      bool QComboBoxPrivateContainer::eventFilter
      is stealing the mouseReleased from you.
      ( i think :)

      Ivan NetskinI Offline
      Ivan NetskinI Offline
      Ivan Netskin
      wrote on last edited by Ivan Netskin
      #7

      @mrjj
      yep , probably these lines :

      case QEvent::MouseButtonRelease: {
      	        bool ignoreEvent = maybeIgnoreMouseButtonRelease && popupTimer.elapsed() < QApplication::doubleClickInterval();
      	
      	        QMouseEvent *m = static_cast<QMouseEvent *>(e);
              if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid()
      	            && !blockMouseReleaseTimer.isActive() && !ignoreEvent
      	            && (view->currentIndex().flags() & Qt::ItemIsEnabled)
      	            && (view->currentIndex().flags() & Qt::ItemIsSelectable)) {
      	            combo->hidePopup();
      	            emit itemSelected(view->currentIndex());
      	            return true;
      	        }
      	        break;
      	    }
      
      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #8

        yep i think so.
        But it seems you can get MouseDown so maybe u can maybe cheat and hax it that way
        and make it close.

        Ivan NetskinI 1 Reply Last reply
        1
        • mrjjM mrjj

          yep i think so.
          But it seems you can get MouseDown so maybe u can maybe cheat and hax it that way
          and make it close.

          Ivan NetskinI Offline
          Ivan NetskinI Offline
          Ivan Netskin
          wrote on last edited by
          #9

          customizing qcombobox is a bit pain. Changing little option may result in
          an unexpected behaviour of the enitre combobox. Is there a way to get expandable list, even if the list inside layout?

          mrjjM 1 Reply Last reply
          0
          • Ivan NetskinI Ivan Netskin

            customizing qcombobox is a bit pain. Changing little option may result in
            an unexpected behaviour of the enitre combobox. Is there a way to get expandable list, even if the list inside layout?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #10

            @Ivan-Netskin
            Well you are fiddling with the core logic. That often leads to side effects.

            Qt is using private classes to increase compatibility but it also often kills
            true reuse as only the virtual function the developers could imagine are
            there to override. But it's worth it :)

            Also note, you can chain event filters so you might be able that way.

            However, if you only need combobox then QListWidget and QPushbutton could
            be use to make fake one. If you need the edit part it becomes more complicated.
            set Min/max and fixed size are still allowed in layouts.

            1 Reply Last reply
            1
            • Ivan NetskinI Offline
              Ivan NetskinI Offline
              Ivan Netskin
              wrote on last edited by Ivan Netskin
              #11

              thanks for reply, the problem is that if i change the widget size,which lies in layout - it will result in growing size of the whole application. This is undesirable behaviour in my case. Also just creating a listview widget without parent and moving it under the QCombobox looks like unclean solution a bit.

              mrjjM 1 Reply Last reply
              0
              • Ivan NetskinI Ivan Netskin

                thanks for reply, the problem is that if i change the widget size,which lies in layout - it will result in growing size of the whole application. This is undesirable behaviour in my case. Also just creating a listview widget without parent and moving it under the QCombobox looks like unclean solution a bit.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #12

                @Ivan-Netskin
                ok. it must be floating then :)
                Before giving up on your custom combobox I would have a look at the eventfilter docs.
                You might be able to put yourself in front and control it that way.

                1 Reply Last reply
                0
                • Ivan NetskinI Offline
                  Ivan NetskinI Offline
                  Ivan Netskin
                  wrote on last edited by
                  #13

                  found something appropriate - http://libqxt.bitbucket.org/doc/tip/qxtcheckcombobox.html

                  mrjjM 1 Reply Last reply
                  0
                  • Ivan NetskinI Ivan Netskin

                    found something appropriate - http://libqxt.bitbucket.org/doc/tip/qxtcheckcombobox.html

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    @Ivan-Netskin
                    But will it stay open ?

                    1 Reply Last reply
                    0
                    • Ivan NetskinI Offline
                      Ivan NetskinI Offline
                      Ivan Netskin
                      wrote on last edited by Ivan Netskin
                      #15

                      From discription it's allowing to select multiple items - that's good enough

                      1 Reply Last reply
                      1

                      • Login

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