Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide2 QCombobox list dropdown issue
Forum Updated to NodeBB v4.3 + New Features

PySide2 QCombobox list dropdown issue

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 4 Posters 1.9k Views
  • 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.
  • A Offline
    A Offline
    ariely
    wrote on last edited by
    #1

    This UI was first set up using PySide and I am now making changes to upgrade it to PySide2, works as expected with PySide. I have a combobox that allows a user to select how a list is ordered. The issue I am running into is that when any item that is not index 0 in the combobox list is selected, subsequent selection of the combobox cause the dropdown list to shift to the selected item.

    This is how it looks when the combobox isn't selected.
    c15efe2e-ac7b-42b0-ba38-6dcfac64394e-image.png

    How it looks when "Modified" is selected, this is index 0 in the combobox.
    4b464942-a1e0-4a0a-ae1a-e734ca6aff7e-image.png

    And how it looks when "Created" is selected, the dropdown is shifted up.
    2bb953e8-7f36-449a-a21d-28031f9a46dd-image.png.

    This is when "Named" is selected.
    ddc4a58d-b603-4202-95d6-ede98a10f7bf-image.png

    Before PySide2 changes, this works and looks like this regardless of the selected item in the combobox. Would like to retain this.
    059694ae-28ee-4092-8714-97695f2c4338-image.png

    I've look through the QT documentation for the QComboBox class, can't seem to find anything. Didn't find anything in styleesheets that could change this either. Any ideas how to use PySide2 but with PySide functionality?

    JonBJ 1 Reply Last reply
    0
    • alomA Offline
      alomA Offline
      alom
      wrote on last edited by
      #2

      @ariely
      I've noticed this on Linux machines (centos 7 and Unbuntu), In windows 10 the drop-down appears to be correct. Sorry I don't have a solution for you

      1 Reply Last reply
      0
      • A ariely

        This UI was first set up using PySide and I am now making changes to upgrade it to PySide2, works as expected with PySide. I have a combobox that allows a user to select how a list is ordered. The issue I am running into is that when any item that is not index 0 in the combobox list is selected, subsequent selection of the combobox cause the dropdown list to shift to the selected item.

        This is how it looks when the combobox isn't selected.
        c15efe2e-ac7b-42b0-ba38-6dcfac64394e-image.png

        How it looks when "Modified" is selected, this is index 0 in the combobox.
        4b464942-a1e0-4a0a-ae1a-e734ca6aff7e-image.png

        And how it looks when "Created" is selected, the dropdown is shifted up.
        2bb953e8-7f36-449a-a21d-28031f9a46dd-image.png.

        This is when "Named" is selected.
        ddc4a58d-b603-4202-95d6-ede98a10f7bf-image.png

        Before PySide2 changes, this works and looks like this regardless of the selected item in the combobox. Would like to retain this.
        059694ae-28ee-4092-8714-97695f2c4338-image.png

        I've look through the QT documentation for the QComboBox class, can't seem to find anything. Didn't find anything in styleesheets that could change this either. Any ideas how to use PySide2 but with PySide functionality?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @ariely
        I don't think this has anything to do with PySide2 per se, nor would I expect it to be. I just tried it under Ubuntu from PySide2 and it does as you say, but it's identical from PyQt5.

        This does not sound like a language thing. Be it PyQt, PySide2 or PySide, they are wrappers around Qt library code. Are you sure you are not talking about a different version of Qt being used? And same Linux desktop/window manager? Is this a window manager thing, that's how it does combos?

        Anyway, since PyQt5 is showing same, I conclude this is correct behaviour (unless someone wants to verify from C++?). I don't know what the old PySide was doing.

        To try to find a combobox in another program, I have gone to Qt Creator > Tools > Options... > C++ > Code Style > Current settings. That is a combobox with 2 choices, and positioning of dropdown choices moves according as item selected. That tells you it's deliberate, default Qt behaviour, not PySide2. But I see other non-Qt apps present their comboboxes differently, so maybe there's no standard or it's a Qt thing under Linux.

        1 Reply Last reply
        0
        • JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          As of 2017:

          https://stackoverflow.com/a/47040124/489865

          1 Reply Last reply
          0
          • alomA Offline
            alomA Offline
            alom
            wrote on last edited by
            #5

            So if this behavior is os dependent and we wanted to match windows handling of a drop down, would this be handled in a custom delegate?
            something like we have to query the combobox's rect and get the qframe of the list view to move it manually?

            JonBJ 1 Reply Last reply
            0
            • alomA alom

              So if this behavior is os dependent and we wanted to match windows handling of a drop down, would this be handled in a custom delegate?
              something like we have to query the combobox's rect and get the qframe of the list view to move it manually?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @alom
              I don't know, but probably yes. If I were trying to achieve something like this, and I thought the Linux behaviour differed from the Windows behaviour, I'd be tempted to have a look/search through Qt source code to see if I could spot what they are doing or what I'm supposed to do. https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qcombobox.cpp.html. Just a thought for you.

              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