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.8k 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 9 Apr 2019, 17:42 last edited by tactical77 4 Sept 2019, 17:45
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Apr 2019, 18:46 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 10 Apr 2019, 07:41 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?

        J J 2 Replies Last reply 10 Apr 2019, 08:11
        0
        • T tactical77
          10 Apr 2019, 07:41

          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?

          J Offline
          J Offline
          JonB
          wrote on 10 Apr 2019, 08:11 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 10 Apr 2019, 10:08
          0
          • J JonB
            10 Apr 2019, 08:11

            @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 10 Apr 2019, 10:08 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
              10 Apr 2019, 07:41

              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?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 10 Apr 2019, 11:27 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 10 Apr 2019, 14:10
              3
              • J jsulm
                10 Apr 2019, 11:27

                @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 10 Apr 2019, 14:10 last edited by
                #7

                @jsulm
                Thanks it works.

                1 Reply Last reply
                0

                4/7

                10 Apr 2019, 08:11

                • Login

                • Login or register to search.
                4 out of 7
                • First post
                  4/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved