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. QCompleter, complete with images

QCompleter, complete with images

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.6k 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.
  • BlasterB Offline
    BlasterB Offline
    Blaster
    wrote on last edited by
    #1

    Hello again ... I have a problem, I want to make an application that inserts images in a QTextEdit and I want that when they are inserted 3 images at least, complete with other predetermined images. The problem is that I have no idea how to implement a completer that will allow me to do this.

    M 1 Reply Last reply
    0
    • BlasterB Blaster

      Hello again ... I have a problem, I want to make an application that inserts images in a QTextEdit and I want that when they are inserted 3 images at least, complete with other predetermined images. The problem is that I have no idea how to implement a completer that will allow me to do this.

      M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      Can you explain how the inserted images will be used to 'complete' to add the other images? Can you give a concrete example by describing what the inserted images contain and what the 'completed' images will contain?

      BlasterB 1 Reply Last reply
      1
      • M mchinand

        Can you explain how the inserted images will be used to 'complete' to add the other images? Can you give a concrete example by describing what the inserted images contain and what the 'completed' images will contain?

        BlasterB Offline
        BlasterB Offline
        Blaster
        wrote on last edited by
        #3

        @mchinand
        I'm doing a hieroglyphic translator. The hieroglyphs have a classification, a name. Then, as you insert a glyph, it is saved in a list and as the hieroglyphs are part of a type of writing they can be completed and I want to use this so I do not have to type a new word in the line of writing

        VRoninV 1 Reply Last reply
        0
        • BlasterB Blaster

          @mchinand
          I'm doing a hieroglyphic translator. The hieroglyphs have a classification, a name. Then, as you insert a glyph, it is saved in a list and as the hieroglyphs are part of a type of writing they can be completed and I want to use this so I do not have to type a new word in the line of writing

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @Blaster said in QCompleter, complete with images:

          inserts images in a QTextEdit
          [...]
          I'm doing a hieroglyphic translator

          hieroglyphics are covered by unicode (for example: https://unicode-table.com/en/#egyptian-hieroglyphs) so you can use normal UTF-8 text, no need for images

          The problem is that I have no idea how to implement a completer

          Create a QStandardItemModel with just 1 column, set the Qt::EditRole to the actual hieroglyphic and the Qt::UserRole to the classification/name then set the completionRole of the QCompleter to Qt::UserRole

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          BlasterB 1 Reply Last reply
          1
          • VRoninV VRonin

            @Blaster said in QCompleter, complete with images:

            inserts images in a QTextEdit
            [...]
            I'm doing a hieroglyphic translator

            hieroglyphics are covered by unicode (for example: https://unicode-table.com/en/#egyptian-hieroglyphs) so you can use normal UTF-8 text, no need for images

            The problem is that I have no idea how to implement a completer

            Create a QStandardItemModel with just 1 column, set the Qt::EditRole to the actual hieroglyphic and the Qt::UserRole to the classification/name then set the completionRole of the QCompleter to Qt::UserRole

            BlasterB Offline
            BlasterB Offline
            Blaster
            wrote on last edited by
            #5

            @VRonin
            Thanks, but I don't know how to insert de unicode text into a QTextEdit.

            @VRonin said in QCompleter, complete with images:

            Create a QStandardItemModel with just 1 column, set the Qt::EditRole to the actual hieroglyphic and the Qt::UserRole to the classification/name then set the completionRole of the QCompleter to Qt::UserRole

            Can you show me how I do that?

            VRoninV 1 Reply Last reply
            0
            • BlasterB Blaster

              @VRonin
              Thanks, but I don't know how to insert de unicode text into a QTextEdit.

              @VRonin said in QCompleter, complete with images:

              Create a QStandardItemModel with just 1 column, set the Qt::EditRole to the actual hieroglyphic and the Qt::UserRole to the classification/name then set the completionRole of the QCompleter to Qt::UserRole

              Can you show me how I do that?

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by VRonin
              #6

              @Blaster said in QCompleter, complete with images:

              Thanks, but I don't know how to insert de unicode text into a QTextEdit

              You don't have to do anything, you can already copy/paste hieroglyphics in QTextEdit. to explicitly insert a character you can use textEdit->cursor().insertHtml("𓀀"); (maybe you'll need to change the font to something that has those characters, maybe this one)

              Can you show me how I do that?

              QAbstractItemModel* model=new QStandardItemModel(this);
              model->insertColumn(0);
              for(uint i=0xF09390AE; i>=0xF0938080;--i){
              model->insertRow(0);
              model->setData(model->index(0,0),QChar(i));
              model->setData(model->index(0,0),QStringLiteral("Description for code %1").arg(i,0,16),Qt::UserRole);
              }
              completer->setModel(model);
              completer->setCompletionRole(Qt::UserRole);
              

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              BlasterB 1 Reply Last reply
              1
              • VRoninV VRonin

                @Blaster said in QCompleter, complete with images:

                Thanks, but I don't know how to insert de unicode text into a QTextEdit

                You don't have to do anything, you can already copy/paste hieroglyphics in QTextEdit. to explicitly insert a character you can use textEdit->cursor().insertHtml("𓀀"); (maybe you'll need to change the font to something that has those characters, maybe this one)

                Can you show me how I do that?

                QAbstractItemModel* model=new QStandardItemModel(this);
                model->insertColumn(0);
                for(uint i=0xF09390AE; i>=0xF0938080;--i){
                model->insertRow(0);
                model->setData(model->index(0,0),QChar(i));
                model->setData(model->index(0,0),QStringLiteral("Description for code %1").arg(i,0,16),Qt::UserRole);
                }
                completer->setModel(model);
                completer->setCompletionRole(Qt::UserRole);
                
                BlasterB Offline
                BlasterB Offline
                Blaster
                wrote on last edited by
                #7

                @VRonin
                I was checking the hieroglyphs which are in unicode and are not all, so I can't use them

                VRoninV 1 Reply Last reply
                0
                • BlasterB Blaster

                  @VRonin
                  I was checking the hieroglyphs which are in unicode and are not all, so I can't use them

                  VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #8

                  I'm not an expert in Egyptian languages so I'll take your word for it, all you have to do then is instead of QChar(i) you'll have QImage(/*...*/) and the loop will be on your set of hieroglyphics. and use cursor().insertImage instead of cursor().insertHtml

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  BlasterB 1 Reply Last reply
                  0
                  • VRoninV VRonin

                    I'm not an expert in Egyptian languages so I'll take your word for it, all you have to do then is instead of QChar(i) you'll have QImage(/*...*/) and the loop will be on your set of hieroglyphics. and use cursor().insertImage instead of cursor().insertHtml

                    BlasterB Offline
                    BlasterB Offline
                    Blaster
                    wrote on last edited by
                    #9

                    @VRonin
                    QCompleter does not show me anything, no image, just a blank box

                    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