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. Applying a Qt::TextFlag to the cells of a QTableWidget
Forum Updated to NodeBB v4.3 + New Features

Applying a Qt::TextFlag to the cells of a QTableWidget

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    Hi all,
    I am trying to apply a Qt::TextFlag like Qt::TextWordWrap to the cells of my QTableWidget but could not find a function to do that.I feel this should be straight forward but can't quite nail it down.
    Any help would be appreciated.

    Why join the navy if you can be a pirate?-Steve Jobs

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you looking for "this":http://qt-project.org/doc/qt-4.8/qtablewidgetitem.html#setFlags ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • musimbateM Offline
        musimbateM Offline
        musimbate
        wrote on last edited by
        #3

        Thanks SGaist for the reply,
        I have tried that function but I got build errors saying that getting the following error:
        QTableWidgetItem::setFlags”: Cant transform a“Qt::TextFlag”into a “Qt::ItemFlags”

        The effect I want is this:When a user writes text in the cell,and text goes beyond the width of the cell,we automatically jump to the next line(in the same cell). I was hopping this setting could help with that.Is this a good way to go about it?

        Why join the navy if you can be a pirate?-Steve Jobs

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ho, sorry, I have mixed both set of flags.

          Did you try with setWordWrap(true) on your QTableWidget ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • musimbateM Offline
            musimbateM Offline
            musimbate
            wrote on last edited by
            #5

            Thanks SGaist,for the input

            I tried setWordWrap(true) and unfortunately it didn t work for me.I was able to get the effect I wanted by inserting QTextEdits into my cells.

            It requires much more handling when adding /removing rows but its the best option I got so far. :-)

            Why join the navy if you can be a pirate?-Steve Jobs

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you thought about making a QStyledItemDelegate ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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