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. Encoding in the QTableView
Forum Updated to NodeBB v4.3 + New Features

Encoding in the QTableView

Scheduled Pinned Locked Moved Solved General and Desktop
47 Posts 3 Posters 16.5k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #41

    Note that the build problem isn't with the delegate but with the MainWindow missing slot implementation.

    @mrjj :-D

    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
    • mrjjM mrjj

      oh a tad to late :)
      https://www.dropbox.com/s/3ajogwsoc7n1zjg/myfirstviewEDITED_hash.zip?dl=0

      ro12man3R Offline
      ro12man3R Offline
      ro12man3
      wrote on last edited by ro12man3
      #42

      @mrjj @SGaist oooohhh guys, thank you!! You are amazing!!!

      It's working. !!!

      The problem is SOLVED! THANK YOU VERY MUCH!!

      1 Reply Last reply
      0
      • mrjjM mrjj

        oh a tad to late :)
        https://www.dropbox.com/s/3ajogwsoc7n1zjg/myfirstviewEDITED_hash.zip?dl=0

        ro12man3R Offline
        ro12man3R Offline
        ro12man3
        wrote on last edited by
        #43

        @mrjj @SGaist
        I started to work and I found one bag.
        My table is:
        Roberto
        Jackson
        1002
        1

        And that's my txt file:
        1002,Hello
        1,How are you

        So the result in the table is
        Roberto
        Jackson
        Hello
        How are you

        It's good. Correct work.
        But if I change 1002 to 10--02 then all const values in the table will become like a second value for 10--02. The result will become:
        Hello
        Hello
        Hello
        How are you

        You can see that, just edit in table Maria to 10--02 and add 10--02 to txt file. What is that?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #44

          @ro12man3 said:

          10--02

          hi
          If you change the first field in file to 10--02
          it it no longer a valid integer.
          Our hash is Int, String
          so that mean use int as key and get back string
          when we read "10--02", and say toInt() we get 0 or something undefined.

          If you need to use a key that is not really a integer. like 10--02, then
          you must change the hash to be Qstring, QString and NOT use toInt() when inserting
          into hash.
          So make sure your text format fits the Hash or strange things will happen :)

          ro12man3R 1 Reply Last reply
          2
          • mrjjM mrjj

            @ro12man3 said:

            10--02

            hi
            If you change the first field in file to 10--02
            it it no longer a valid integer.
            Our hash is Int, String
            so that mean use int as key and get back string
            when we read "10--02", and say toInt() we get 0 or something undefined.

            If you need to use a key that is not really a integer. like 10--02, then
            you must change the hash to be Qstring, QString and NOT use toInt() when inserting
            into hash.
            So make sure your text format fits the Hash or strange things will happen :)

            ro12man3R Offline
            ro12man3R Offline
            ro12man3
            wrote on last edited by
            #45

            @mrjj Ok. It was

            // In .h file:
            QHash<int, QString> hash;
            ......
              hash[fields[0].toInt()] = fields[1] ;
            ......
            // In .cpp file:
            QString mapped = hash.value(value.toInt());
            

            After editing it's:

            // In .h file:
            QHash<QString, QString> hash;
            ......
              hash[fields[0]] = fields[1] ;
            ......
            // In .cpp file:
            QString mapped = hash.value(value);
            

            Is it correct?

            1 Reply Last reply
            1
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #46

              hi
              yes, seems fine. good work.
              i think you might need
              QString mapped = hash.value(value.toString);
              as value is variant and hash wants string.

              ro12man3R 1 Reply Last reply
              2
              • mrjjM mrjj

                hi
                yes, seems fine. good work.
                i think you might need
                QString mapped = hash.value(value.toString);
                as value is variant and hash wants string.

                ro12man3R Offline
                ro12man3R Offline
                ro12man3
                wrote on last edited by
                #47

                @mrjj Wooow I'm so happy, really :D Thank you :) I will study and study and study :)

                1 Reply Last reply
                1

                • Login

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