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. How to customize QComboBox's layout
Forum Updated to NodeBB v4.3 + New Features

How to customize QComboBox's layout

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.8k 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.
  • L Offline
    L Offline
    lucadanieli
    wrote on last edited by
    #1

    Hi all,

    I don't find the answer in internet. Is there any chance to customize QComboBox in order to make it fit properly the surrounding style of the program? I mean changing the color of the Bar, and not of the popup area, for example. And the shape of the menu, the style of the rows and so on.

    The more the opportunities, the better it is.

    Thanks,
    Luca

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      If you need basic colour settings changed, use the stylesheet way.
      If you need advanced changes, you are looking at subclassing the QComboBox and implement the paintEvent etc
      Greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        You can substitute your completely customized view via "QComboBox::setView":http://qt-project.org/doc/qt-5/qcombobox.html#setView or even take full control of the item delegate via "QComboBox::setItemDelegate":http://qt-project.org/doc/qt-5/qcombobox.html#setItemDelegate - the latter one is used to draw the contents of the list that pops up when you use the combobox.

        If you just want the combobox to fit its surroundings, maybe you only need to set its parent properly. Widgets normally inherit style and palette from their parents. And if the parent was using a style sheet, you could make use of that, too (depending on the style sheet it might not be completely straight forward, however).

        The "QComboBox::paintEvent":http://qt-project.org/doc/qt-5/qcombobox.html#paintEvent of course would give you complete control of the combo box-painting itself (I guess not of the popup-list, though - but that would be covered by the formerly mentioned item delegate).

        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