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. Controlling the direction of a QComboBox's drop-down menu
Forum Updated to NodeBB v4.3 + New Features

Controlling the direction of a QComboBox's drop-down menu

Scheduled Pinned Locked Moved General and Desktop
10 Posts 6 Posters 8.6k 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
    buggex
    wrote on last edited by
    #1

    Is there any way to choose if the drop-down menu should appear bellow or above the QComboBox?

    I have a QComboBox at the bottom of a page and when I click it the menu drops below the box and only shows one item and a scroll-bar. Would like it to appear above the box instead.

    Using QT 3.3.6

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Not that I'm aware of. The public API provides no means for this.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        Also, 3.3.6 is an extremely old Qt version. If circumstances allow, upgrading to something more modern would be a benefit. (Though, if it's legacy code, I understand the situation too!)

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

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

          While I generally agree with the updating advice, I think that for this case, it would not help. Even in 4.7.3 I know of no way to force this behavior.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            octal
            wrote on last edited by
            #5

            One solution to explore is :

            • creating a subclass of QComboBox ;
            • reimplementing the QComboBox::showPopup() function.

            However, if you look at showPopup source-code, you'll see that they use a lot of private stuff (pimpl), so you won't have access to it in your class, since it's private and not protected.

            The way to go would then be to move the view used to render the popup. You can access it by calling QComboBox::view(). It should then give something like :

            @
            void MyComboBox::showPopup()
            {
            QAbstractItemView *popupView = view();
            popupView->move(...);

            QComboBox::showPopup();
            

            }
            @

            1 Reply Last reply
            0
            • B Offline
              B Offline
              buggex
              wrote on last edited by
              #6

              unfortunately showPopup() and view() is not available i version 3.3.6 and updating to a new version of Qt is not an option

              [quote author="octal" date="1314262343"]One solution to explore is :

              • creating a subclass of QComboBox ;
              • reimplementing the QComboBox::showPopup() function.

              However, if you look at showPopup source-code, you'll see that they use a lot of private stuff (pimpl), so you won't have access to it in your class, since it's private and not protected.

              The way to go would then be to move the view used to render the popup. You can access it by calling QComboBox::view(). It should then give something like :

              @
              void MyComboBox::showPopup()
              {
              QAbstractItemView *popupView = view();
              popupView->move(...);

              QComboBox::showPopup();
              

              }
              @[/quote]

              1 Reply Last reply
              0
              • O Offline
                O Offline
                octal
                wrote on last edited by
                #7

                Indeed, your Qt version might be an issue.

                However, since I've never used Qt 3.x, I can't help you more. Good luck for finding a solution.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  [quote author="buggex" date="1314270208"]unfortunately showPopup() and view() is not available i version 3.3.6 and updating to a new version of Qt is not an option

                  [/quote]

                  No, but according to the docs, you do have a virtual popup() method and a method that returns a listBox() method. That is basically the Qt 3 version of showPopup() and view().

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    buggex
                    wrote on last edited by
                    #9

                    will try solving my problem another way, thanks for the help

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      AFAIK the combobox shows the popup by default below the box, if it fits there. If not, it tries to position it upwards. This is done automatically...

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      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