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. Creating QTableWidget Header with multilinetext
QtWS25 Last Chance

Creating QTableWidget Header with multilinetext

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 6.9k 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.
  • D Offline
    D Offline
    doshirushabh
    wrote on last edited by doshirushabh
    #1

    Hello
    I was trying to create multiline text in Header of QTableWidget. Nothing worked for me. The Cells can be created with multiline text but header am not sure if there is a simple way. Could anyone help me with this

    Thanks !!

    R 1 Reply Last reply
    0
    • D doshirushabh

      Hello
      I was trying to create multiline text in Header of QTableWidget. Nothing worked for me. The Cells can be created with multiline text but header am not sure if there is a simple way. Could anyone help me with this

      Thanks !!

      R Offline
      R Offline
      Renn
      wrote on last edited by Renn
      #2

      @doshirushabh Already tried this yet?

      ui->tableWidget->setColumnCount(1);
      ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Something"));

      D 1 Reply Last reply
      0
      • RatzzR Offline
        RatzzR Offline
        Ratzz
        wrote on last edited by Ratzz
        #3

        Hi and welcome.
        You can use \n to make header with multi-line text.

        --Alles ist gut.

        1 Reply Last reply
        0
        • R Renn

          @doshirushabh Already tried this yet?

          ui->tableWidget->setColumnCount(1);
          ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Something"));

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

          @Renn
          Hello. Thanks but i was able to set single line text like "Something" But Multiline even with \n didnt work.

          RatzzR 1 Reply Last reply
          0
          • D doshirushabh

            @Renn
            Hello. Thanks but i was able to set single line text like "Something" But Multiline even with \n didnt work.

            RatzzR Offline
            RatzzR Offline
            Ratzz
            wrote on last edited by
            #5

            @doshirushabh
            I did this way

            table->setColumnCount(1);
            table->setHorizontalHeaderLabels(QString("HEADER 1 \n Header_nextline").split(";"));

            --Alles ist gut.

            D 1 Reply Last reply
            0
            • RatzzR Ratzz

              @doshirushabh
              I did this way

              table->setColumnCount(1);
              table->setHorizontalHeaderLabels(QString("HEADER 1 \n Header_nextline").split(";"));
              D Offline
              D Offline
              doshirushabh
              wrote on last edited by
              #6

              @Ratzz
              Hello. Thanks for the help. This works . The reason it didnt work is we have some docking undocking and some global settings which didnt make it work when docked. Thanks again !!

              RatzzR 1 Reply Last reply
              0
              • D doshirushabh

                @Ratzz
                Hello. Thanks for the help. This works . The reason it didnt work is we have some docking undocking and some global settings which didnt make it work when docked. Thanks again !!

                RatzzR Offline
                RatzzR Offline
                Ratzz
                wrote on last edited by
                #7

                @doshirushabh
                Once your problem is solved please use the Topic Tools button to mark as Solved.
                Thank you!

                --Alles ist gut.

                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