Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Get value of a tuple with a list

Get value of a tuple with a list

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 886 Views
  • 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.
  • L Offline
    L Offline
    LT-K101
    wrote on 29 Apr 2022, 07:27 last edited by
    #1

    Hi,
    I have a tuple within a list and I'm trying to get the last value of the tuple which is at index 16. When i run Name = self.ui.label_574.setText(data[0][0]) works but when I run Age = self.ui.label_574.setText(data[0][16] I get this error message setText(self, str): argument 1 has unexpected type 'int'. Please any help on what I'm doing wrong.

    J L 2 Replies Last reply 29 Apr 2022, 07:30
    0
    • L LT-K101
      29 Apr 2022, 07:27

      Hi,
      I have a tuple within a list and I'm trying to get the last value of the tuple which is at index 16. When i run Name = self.ui.label_574.setText(data[0][0]) works but when I run Age = self.ui.label_574.setText(data[0][16] I get this error message setText(self, str): argument 1 has unexpected type 'int'. Please any help on what I'm doing wrong.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 29 Apr 2022, 07:30 last edited by
      #2

      @LT-K101 The error is actually self-explanatory: you are trying to set an int where string is expected. You need to convert int to QString.

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

      L 1 Reply Last reply 29 Apr 2022, 07:37
      2
      • L LT-K101
        29 Apr 2022, 07:27

        Hi,
        I have a tuple within a list and I'm trying to get the last value of the tuple which is at index 16. When i run Name = self.ui.label_574.setText(data[0][0]) works but when I run Age = self.ui.label_574.setText(data[0][16] I get this error message setText(self, str): argument 1 has unexpected type 'int'. Please any help on what I'm doing wrong.

        L Offline
        L Offline
        LT-K101
        wrote on 29 Apr 2022, 07:36 last edited by
        #3

        @LT-K101 I solved it by doing Age = self.ui.label_574.setText(str(data[0][16]))

        1 Reply Last reply
        0
        • J jsulm
          29 Apr 2022, 07:30

          @LT-K101 The error is actually self-explanatory: you are trying to set an int where string is expected. You need to convert int to QString.

          L Offline
          L Offline
          LT-K101
          wrote on 29 Apr 2022, 07:37 last edited by
          #4

          @jsulm Thanks a lot

          1 Reply Last reply
          0

          2/4

          29 Apr 2022, 07:30

          • Login

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