Important: Please read the Qt Code of Conduct -

PySide2 QCombobox list dropdown issue

  • 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.

    How it looks when "Modified" is selected, this is index 0 in the combobox.

    And how it looks when "Created" is selected, the dropdown is shifted up.

    This is when "Named" is selected.

    Before PySide2 changes, this works and looks like this regardless of the selected item in the combobox. Would like to retain this.

    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?

  • @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

  • Banned

    Do keep in mind that pyside2 is behind the ball when it comes to getting up to par on Qt5 so there are bound to be issues such as this. So are you really needing the LGPL license or will the GPL license suffice.

    As to fixing the issue in pyside2 -- I would say until they actually get that fixed (assuming they do) you can simply sub-class that object and fix it yourself -- heck once you fix it you might even send that into the pyside2 folks and they might just implement your fix -- aka do not wait around for someone to address your issues when it comes to open source code -- pick up that ball and run with it yourself aka be active not passive

  • @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.

  • Banned

    @JonB I am not sure about your question but to clarify -- they are comparing pyside vs pyside2 -- which means they are comparing pyqt4 vs pyqt5 which you denoted acts the same way --thus-- basically comparing Qt4 vs Qt5 and saying that it changed significantly from 4 to 5 in a way they do not appreciate.

    So the issue is now making the Qt5 version (in whatever flavor one chooses) act like the Qt4 version which would probably mean as I said -- sub-classing the object and changing that behavior or waiting around until Qt5 gets altered (if it ever does)

  • 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?

  • @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. Just a thought for you.

  • Banned

    Okay the handling of the positioning of the dropdown I would imagine is contained within the QComboBox not the delegate and you can verify this by simply creating a combobox without a delegate and checking its functionality

    So if that is the case, to modify it you would need to modify its behavior which you do by sub-classing it to make a combo box that works the way you want it to work

Log in to reply