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 set QComboBox text elide mode

How to set QComboBox text elide mode

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

    Is there a way to set the text elide mode for the text shown in a QComboBox (not the popup list)?

    It is possible to set it for items in the popup list

    @myCmb->view()->setTextElideMode()@

    but I did not find any way to set it for the text shown in the QComboBox.

    Thanks in advance for your help

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

      For an editable combo box: certainly not. A QLineEdit is used, and that class can not elide text. For a non-editable I am not sure. I don't think so by default, but the source will tell you for sure.

      However, you should be able to add this to the QComboBox using subclassing. The ingredients are all there, I think. I think that you can use QStyle to actually do most of the rendering for you (in the case of the non-editable combo, the editable one you just call the base implementation). You just need to use QFontMetrics to generate an elided current text to set in the QStyleOptionComboBox instance you pass to the QStyle for rendering.

      However, also make a feature suggestion in Jira. I think it makes sense to have.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalos
        wrote on last edited by
        #3

        Andre,

        that was a great help.
        Thank you very much!

        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