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. QTableWidget header text
Qt 6.11 is out! See what's new in the release blog

QTableWidget header text

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 40.9k 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.
  • T Offline
    T Offline
    thehilmisu
    wrote on last edited by
    #1

    Hi everyone,
    My problem is simple but i am new at qt. So, my problem is that i have a QTableWidget and i have to set its header text.
    i have 7 columns and by default header texts are 1,2,3,...,7 .

    How can i change it's text?

    Thanks in advance.

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Have a look at the "qtablewidget docs":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderLabels.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      2
      • T Offline
        T Offline
        thehilmisu
        wrote on last edited by
        #3

        [quote author="Eddy" date="1325661070"]Have a look at the "qtablewidget docs":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderLabels.[/quote]

        Thanks. i tried this,

        @QTableWidgetItem *header1 = new QTableWidgetItem();
        header1->setText("Switch "ON" to Load");
        tableWidget->setHorizontalHeaderItem(0,header1);

        QTableWidgetItem *header2 = new QTableWidgetItem();
        header2->setText("Parameter No.");
        tableWidget->setHorizontalHeaderItem(1,header2);
        

        @

        It works, i did that for all seven column. but is this a good way?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          joonhwan
          wrote on last edited by
          #4

          one liner could do that.

          @
          tableWiget->setHorizontalHeaderLabels(QStringList() << "Switch.." << "Parameter...");
          @

          joonhwan at gmail dot com

          1 Reply Last reply
          1
          • T Offline
            T Offline
            thehilmisu
            wrote on last edited by
            #5

            [quote author="joonhwan" date="1325669987"]one liner could do that.

            @
            tableWiget->setHorizontalHeaderLabels(QStringList() << "Switch.." << "Parameter...");
            @[/quote]

            thanks .

            1 Reply Last reply
            2
            • D Offline
              D Offline
              Djay96
              wrote on last edited by
              #6

              thank you very much ...

              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