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 limit header text word wrap ?
QtWS25 Last Chance

How to limit header text word wrap ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 797 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.
  • M Offline
    M Offline
    mehmety888
    wrote on last edited by
    #1

    Hi,

    I used the following line of code in my custom class (which is subclassed from QHeaderView) to implement word wrap in headers.

    this->setDefaultAlignment(Qt::AlignCenter | static_cast<Qt::Alignment>(Qt::TextWordWrap));
    

    It works, however I want to limit it (no more than 2 lines)

    However, at some point it starts vertical clipping of the text and it looks ugly, like below: Is there any way to stop word wrap when there are 2 lines of text ?

    column2.JPG
    column.JPG

    Another possible solution may be start elide with multiple lines, and I tried it but elide and word wrap cancel each other. Is it possible to have elide middle with multiple lines ?

    Thank you,

    kshegunovK 1 Reply Last reply
    1
    • D Offline
      D Offline
      DzCode
      wrote on last edited by
      #2

      I didnt know if there can e both elide mode and text wordwrap. If we can do, I also want to learn it

      1 Reply Last reply
      0
      • M mehmety888

        Hi,

        I used the following line of code in my custom class (which is subclassed from QHeaderView) to implement word wrap in headers.

        this->setDefaultAlignment(Qt::AlignCenter | static_cast<Qt::Alignment>(Qt::TextWordWrap));
        

        It works, however I want to limit it (no more than 2 lines)

        However, at some point it starts vertical clipping of the text and it looks ugly, like below: Is there any way to stop word wrap when there are 2 lines of text ?

        column2.JPG
        column.JPG

        Another possible solution may be start elide with multiple lines, and I tried it but elide and word wrap cancel each other. Is it possible to have elide middle with multiple lines ?

        Thank you,

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @mehmety888 said in How to limit header text word wrap ?:

        Is it possible to have elide middle with multiple lines ?

        Not as far as I know. How should the framework know where to wrap and where to elide?

        Read and abide by the Qt Code of Conduct

        D 1 Reply Last reply
        0
        • kshegunovK kshegunov

          @mehmety888 said in How to limit header text word wrap ?:

          Is it possible to have elide middle with multiple lines ?

          Not as far as I know. How should the framework know where to wrap and where to elide?

          D Offline
          D Offline
          DzCode
          wrote on last edited by
          #4

          @kshegunov As I understood, wordwrap and elide mode cannot be used at the same time.

          However, is it possible to limit wordwrap line size? For eample in my project, it is only wanted that there should be maximum 3 or 4 lines. However, if I continue to shrink the column it becomes 5 lines of header name. I wanted to limit it to 4

          kshegunovK 1 Reply Last reply
          0
          • D DzCode

            @kshegunov As I understood, wordwrap and elide mode cannot be used at the same time.

            However, is it possible to limit wordwrap line size? For eample in my project, it is only wanted that there should be maximum 3 or 4 lines. However, if I continue to shrink the column it becomes 5 lines of header name. I wanted to limit it to 4

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @DzCode said in How to limit header text word wrap ?:

            However, is it possible to limit wordwrap line size? For eample in my project, it is only wanted that there should be maximum 3 or 4 lines. However, if I continue to shrink the column it becomes 5 lines of header name. I wanted to limit it to 4

            Not as far as I know, but what about using eliding and setting the header's size instead? Give it two rows of vertical space and elide on the right, should work, I think.

            Read and abide by the Qt Code of Conduct

            D 1 Reply Last reply
            0
            • kshegunovK kshegunov

              @DzCode said in How to limit header text word wrap ?:

              However, is it possible to limit wordwrap line size? For eample in my project, it is only wanted that there should be maximum 3 or 4 lines. However, if I continue to shrink the column it becomes 5 lines of header name. I wanted to limit it to 4

              Not as far as I know, but what about using eliding and setting the header's size instead? Give it two rows of vertical space and elide on the right, should work, I think.

              D Offline
              D Offline
              DzCode
              wrote on last edited by
              #6

              @kshegunov It is very bad not to hve any feature to limit wordwrap size

              Christian EhrlicherC 1 Reply Last reply
              0
              • D DzCode

                @kshegunov It is very bad not to hve any feature to limit wordwrap size

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @DzCode said in How to limit header text word wrap ?:

                It is very bad not to hve any feature to limit wordwrap size

                Feel free to provide a patch for it...

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved