Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Searching for appropriate element

Searching for appropriate element

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 1.4k 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.
  • S Offline
    S Offline
    Sillimon
    wrote on last edited by
    #1

    Hi hi !
    I'd like to display 2 lines of 3 QString each and make some of those QString alterable (only by clicking a character of that QString and modify it) and some others not.

    For now, i'm building a big QString and simply displaying it in a TextArea which makes the code behind awfull.
    Does someone have an idea that could fit my needs ? Using QString or not ?

    I'd love something like that :
    read-only ------------ alterable by clicking a character and then modify it with a keyboard input
    00000000 ------------ BF BD 6C 75 6A 68 00 67 ------------ a b c d e f g h
    00000008 ------------ 62 63 64 72 6C EF 00 00 ------------ i j k l m n o p

    Those ain't the real values but no minds.

    There's probably a really basic and clean solution to this but i can't find it... Qt got a pretty big doc.

    aha_1980A 1 Reply Last reply
    0
    • S Sillimon

      Hi hi !
      I'd like to display 2 lines of 3 QString each and make some of those QString alterable (only by clicking a character of that QString and modify it) and some others not.

      For now, i'm building a big QString and simply displaying it in a TextArea which makes the code behind awfull.
      Does someone have an idea that could fit my needs ? Using QString or not ?

      I'd love something like that :
      read-only ------------ alterable by clicking a character and then modify it with a keyboard input
      00000000 ------------ BF BD 6C 75 6A 68 00 67 ------------ a b c d e f g h
      00000008 ------------ 62 63 64 72 6C EF 00 00 ------------ i j k l m n o p

      Those ain't the real values but no minds.

      There's probably a really basic and clean solution to this but i can't find it... Qt got a pretty big doc.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Sillimon

      I'd say you are searching for a QTableWidget.

      Qt has to stay free or it will die.

      S 1 Reply Last reply
      2
      • aha_1980A aha_1980

        @Sillimon

        I'd say you are searching for a QTableWidget.

        S Offline
        S Offline
        Sillimon
        wrote on last edited by
        #3

        @aha_1980 said in Searching for appropriate element:

        @Sillimon

        I'd say you are searching for a QTableWidget.

        It means that i should have one column for each "editable cell" ?
        That would be between 13 and 25 columns.
        But it has a bunch of really useful properties though...

        I think i'm searching too far when it's just that simple.
        I'm trying it, thank you again !

        aha_1980A 1 Reply Last reply
        0
        • S Sillimon

          @aha_1980 said in Searching for appropriate element:

          @Sillimon

          I'd say you are searching for a QTableWidget.

          It means that i should have one column for each "editable cell" ?
          That would be between 13 and 25 columns.
          But it has a bunch of really useful properties though...

          I think i'm searching too far when it's just that simple.
          I'm trying it, thank you again !

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sillimon said in Searching for appropriate element:

          It means that i should have one column for each "editable cell" ?
          That would be between 13 and 25 columns.

          That depends on your needs. Maybe you just need three columns, each containing the string?

          Qt has to stay free or it will die.

          S 1 Reply Last reply
          0
          • aha_1980A aha_1980

            @Sillimon said in Searching for appropriate element:

            It means that i should have one column for each "editable cell" ?
            That would be between 13 and 25 columns.

            That depends on your needs. Maybe you just need three columns, each containing the string?

            S Offline
            S Offline
            Sillimon
            wrote on last edited by Sillimon
            #5

            @aha_1980
            Yeah...
            Actually, i can't do it as i thought, using a lot of columns. The design won't fit.

            Using TableView with 3 Columns of String would be the best option but I'm now wondering how i can check user entries...
            I'm trying an event on DataChanged inside the model.

            aha_1980A 1 Reply Last reply
            0
            • S Sillimon

              @aha_1980
              Yeah...
              Actually, i can't do it as i thought, using a lot of columns. The design won't fit.

              Using TableView with 3 Columns of String would be the best option but I'm now wondering how i can check user entries...
              I'm trying an event on DataChanged inside the model.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi @Sillimon

              (If your model get's a bit more complex, you should have a look at QTableView and your own model implementation instead using QTableWidget)

              Regarding the user entries: that's usually done with a QInputValidator, which forbids entering invalid values (before the data is changed at all).

              Qt has to stay free or it will die.

              S 1 Reply Last reply
              1
              • aha_1980A aha_1980

                Hi @Sillimon

                (If your model get's a bit more complex, you should have a look at QTableView and your own model implementation instead using QTableWidget)

                Regarding the user entries: that's usually done with a QInputValidator, which forbids entering invalid values (before the data is changed at all).

                S Offline
                S Offline
                Sillimon
                wrote on last edited by Sillimon
                #7

                @aha_1980 said in Searching for appropriate element:

                Hi @Sillimon

                Hi hi !

                (If your model get's a bit more complex, you should have a look at QTableView and your own model implementation instead using QTableWidget)

                Yeah, i'm already using QTableView since i didn't learn to work on C++ side yet.
                I changed my methods and i'm building vectors of QString (each "line" being an vector's index value).
                I'm even taking in count latin-1 char (thanks again to you and the others for explanations) this way :

                m_alpha.clear();
                    QString alpha;
                    if(m_chip->getCardType() == "Mifare4K")
                    {
                        for (size_t i = 0; i < 8; ++i)
                        {
                            const QChar c = QLatin1Char(readData.at(i));
                            if(c.isPrint())
                            {
                                alpha.push_back(c);
                                alpha.append(" ");
                            }
                            else
                            {
                                alpha.append(". ");
                            }
                        }
                        m_alpha.push_back(alpha);
                        alpha = "";
                
                        for(size_t i = 8; i < 16; i++)
                        {
                            const QChar c = QChar::fromLatin1(readData.at(i));
                            if(c.isPrint())
                            {
                                alpha.push_back(c);
                                alpha.append(" ");
                            }
                            else
                            {
                                alpha.append(". ");
                            }
                        }
                        m_alpha.push_back(alpha);
                    }
                    else if(m_chip->getCardType() == "ISO15693")
                    {
                        for (size_t i = 0; i < 4; ++i)
                        {
                            const QChar c = QLatin1Char(readData.at(i));
                            if(c.isPrint())
                            {
                                alpha.push_back(c);
                                alpha.append(" ");
                            }
                            else
                            {
                                alpha.append(". ");
                            }
                        }
                        m_alpha.push_back(alpha);
                    }
                    else
                    {
                        m_alpha.push_back("Invalid chip");
                    }
                

                On QML side, i build it this way :

                QML mouseArea.onClicked :
                tvmodel.append({hexdump: readWrite.getHexdumpLine(1), hexa: readWrite.getHexaLine(1), alpha: readWrite.getAlphaLine(1)})
                if(Card.getCardType() === "Mifare4K")
                {
                        tvmodel.append({hexdump: readWrite.getHexdumpLine(2), hexa: readWrite.getHexaLine(2), alpha: readWrite.getAlphaLine(2)})
                }
                
                .cpp :
                QString ReadWrite::getAlphaLine(int line)
                {
                    QString alpha;
                    alpha = m_alpha.at(line-1);
                    return alpha;
                }
                

                I now have something good in display !
                Currently working on writing side.

                Regarding the user entries: that's usually done with a QInputValidator, which forbids entering invalid values (before the data is changed at all).

                That's exactly what i'm looking for ! Keeping that in mind for once i did the writing correct implementation.

                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