Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Creating QTableWidget Header with multilinetext

    General and Desktop
    3
    7
    6066
    Loading More Posts
    • 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
      doshirushabh last edited by 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 1 Reply Last reply Reply Quote 0
      • R
        Renn @doshirushabh last edited by Renn

        @doshirushabh Already tried this yet?

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

        D 1 Reply Last reply Reply Quote 0
        • Ratzz
          Ratzz last edited by Ratzz

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

          --Alles ist gut.

          1 Reply Last reply Reply Quote 0
          • D
            doshirushabh @Renn last edited by

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

            Ratzz 1 Reply Last reply Reply Quote 0
            • Ratzz
              Ratzz @doshirushabh last edited by

              @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 Reply Quote 0
              • D
                doshirushabh @Ratzz last edited by

                @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 !!

                Ratzz 1 Reply Last reply Reply Quote 0
                • Ratzz
                  Ratzz @doshirushabh last edited by

                  @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 Reply Quote 0
                  • First post
                    Last post