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. Set Headers in Qlistwidget and Qtablewidget
Forum Updated to NodeBB v4.3 + New Features

Set Headers in Qlistwidget and Qtablewidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 4.7k 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
    tactical77
    wrote on last edited by tactical77
    #1

    Hi,

    I'm pretty new to qt and have to finish some stuff for school. I figured out how to add items to Qlistwidget and Qtablewidget but I need to have headers similar to the ones in the picture.
    I also have already a cli program from my last homework which should be used to read in data from a text file and store it in objects and then in vectors. Can I just use it and
    export the data into Qlistwidget?

    (https://ibb.co/tc1hFyh)

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

      Hi and welcome to devnet,

      Do you mean the text ? If so, yes, you can use QTableWidget::setVerticalHeaderLabels.

      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
      1
      • T Offline
        T Offline
        tactical77
        wrote on last edited by
        #3

        Thanks it worked. I have another question. I know how to add strings in qlistwidget but I need to add a string and some doubles and integers all in the same row?

        JonBJ jsulmJ 2 Replies Last reply
        0
        • T tactical77

          Thanks it worked. I have another question. I know how to add strings in qlistwidget but I need to add a string and some doubles and integers all in the same row?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @tactical77
          QListWidgetItems are "typically" used to display text, icon & checkbox. Are you sure you don't mean to use a QTableWidget for "add a string and some doubles and integers all in the same row"?

          T 1 Reply Last reply
          0
          • JonBJ JonB

            @tactical77
            QListWidgetItems are "typically" used to display text, icon & checkbox. Are you sure you don't mean to use a QTableWidget for "add a string and some doubles and integers all in the same row"?

            T Offline
            T Offline
            tactical77
            wrote on last edited by
            #5

            @JonB
            I basically have some client data which is stored in objects and I have to create both a qlistwidget and a qtablewidget. Probably just in order to learn to use both of them. But each one has basically the same data output.

            1 Reply Last reply
            0
            • T tactical77

              Thanks it worked. I have another question. I know how to add strings in qlistwidget but I need to add a string and some doubles and integers all in the same row?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @tactical77 Use https://doc.qt.io/qt-5/qstring.html#number-2 and https://doc.qt.io/qt-5/qstring.html#number-6 and concatenate the strings...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              3
              • jsulmJ jsulm

                @tactical77 Use https://doc.qt.io/qt-5/qstring.html#number-2 and https://doc.qt.io/qt-5/qstring.html#number-6 and concatenate the strings...

                T Offline
                T Offline
                tactical77
                wrote on last edited by
                #7

                @jsulm
                Thanks it works.

                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