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 cut of right side of combo box text instead of left size when not enough space to show all text
Forum Updated to NodeBB v4.3 + New Features

How to cut of right side of combo box text instead of left size when not enough space to show all text

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 312 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.
  • dporobicD Offline
    dporobicD Offline
    dporobic
    wrote on last edited by
    #1

    I have a combo box that can be shrunk to a size where not all text fits, currently the text on the left side is cut of in such a case, is there a possibility to cut of on the right side?

    321380a2-d25d-42e5-94c3-847e49bcbb2f-image.png

    https://github.com/ksnip/ksnip

    1 Reply Last reply
    0
    • dporobicD Offline
      dporobicD Offline
      dporobic
      wrote on last edited by
      #3

      Thanks for the hint, got this solution working for me:

      bbb301a6-424f-41a4-aa4a-d3294e0fc558-image.png

      The only part that I'm not happy with is the hard coded button width, would have been nice if I could find that dynamically.

      https://github.com/ksnip/ksnip

      JoeCFDJ 1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #2
            auto fit_text = m_fileNameLabel->fontMetrics().elidedText( file_info.fileName(), Qt::ElideRight, m_fileNameLabel->size().width() );
            m_fileNameLabel->setText( fit_text );
        

        I am using elidedText for my qlabel. It may be useful for you as well.

        1 Reply Last reply
        2
        • dporobicD Offline
          dporobicD Offline
          dporobic
          wrote on last edited by
          #3

          Thanks for the hint, got this solution working for me:

          bbb301a6-424f-41a4-aa4a-d3294e0fc558-image.png

          The only part that I'm not happy with is the hard coded button width, would have been nice if I could find that dynamically.

          https://github.com/ksnip/ksnip

          JoeCFDJ 1 Reply Last reply
          0
          • dporobicD dporobic

            Thanks for the hint, got this solution working for me:

            bbb301a6-424f-41a4-aa4a-d3294e0fc558-image.png

            The only part that I'm not happy with is the hard coded button width, would have been nice if I could find that dynamically.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #4

            @dporobic query the width of the button inside resizeEvent(QResizeEvent * event). It is dynamic.

            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