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. Wrapping a word/text with a hyphen

Wrapping a word/text with a hyphen

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

    Hi,

    I am using "setWordWrapMode(QTextOption::WrapAnywhere)" in a QTextBrowser to signal the text wrap mode. The wrapping works fine but I've got no hyphen (-) at the end of a text line. Is there a way to set the word wrapping mode to enable a hyphen at lineend?

    Thanks a lot and best regards
    Lukas

    JonBJ J.HilkJ 2 Replies Last reply
    1
    • L LukasGin

      Hi,

      I am using "setWordWrapMode(QTextOption::WrapAnywhere)" in a QTextBrowser to signal the text wrap mode. The wrapping works fine but I've got no hyphen (-) at the end of a text line. Is there a way to set the word wrapping mode to enable a hyphen at lineend?

      Thanks a lot and best regards
      Lukas

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @LukasGin
      I do not see any documentation anywhere which indicates that Qt would put in a hyphen for you where it breaks a word to wrap. Are you saying you are putting in your own QChar::SoftHyphen?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LukasGin
        wrote on last edited by
        #3

        No, I dont putting my own hyphen. It currently just wraps a word at the line end without a hyphen. What I want to have (if possible) is to force Qt to insert a hyphen at the correct word position for hyphenation at a linened.

        1 Reply Last reply
        0
        • L LukasGin

          Hi,

          I am using "setWordWrapMode(QTextOption::WrapAnywhere)" in a QTextBrowser to signal the text wrap mode. The wrapping works fine but I've got no hyphen (-) at the end of a text line. Is there a way to set the word wrapping mode to enable a hyphen at lineend?

          Thanks a lot and best regards
          Lukas

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          Hi @LukasGin and welcome

          I don't think there is a predefined way to add a hyphen and the end of a line, when a word was split.

          I only thing I can think of to archive this, is to make your own widget and override paintEvent and add a hyphen in the needed places.

          Take a look at this elided label example, where there's done something similar
          https://doc.qt.io/qt-5/qtwidgets-widgets-elidedlabel-example.html


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            LukasGin
            wrote on last edited by
            #5

            Ok, thanks a lot!

            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