Qt Forum

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

    QTableWidget header text

    General and Desktop
    4
    6
    35327
    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.
    • T
      thehilmisu last edited by

      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 Reply Quote 0
      • E
        Eddy last edited by

        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 Reply Quote 1
        • T
          thehilmisu last edited by

          [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 Reply Quote 0
          • J
            joonhwan last edited by

            one liner could do that.

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

            joonhwan at gmail dot com

            1 Reply Last reply Reply Quote 0
            • T
              thehilmisu last edited by

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

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

              thanks .

              1 Reply Last reply Reply Quote 2
              • D
                Djay96 last edited by

                thank you very much ...

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post