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. Which Widget is used with the ItemDelegate?
Forum Updated to NodeBB v4.3 + New Features

Which Widget is used with the ItemDelegate?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 694 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.
  • E Offline
    E Offline
    EL-jos
    wrote on last edited by
    #1

    Hello everyone,
    I make a thcatt(messenger) software and I have reached the stage of viewing the message with emoji and I don't know how to do it, here is an image as an example of a conversation:
    0_1541700001616_Capture.PNG

    so @SGaist offered me to use the QItemDelegate, since I didn't know how to do it so @mrjj gave me a link to follow a training on the QItemDelegate and I finished the training well but it doesn't really help me to solve my problem because I don't know from the image posted above where the view is? what model used? to have a result like the one of whatsapp posted in the image above

    Thank you for your help in advance

    JonBJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      use the QItemDelegate

      The class is now deprecated, you should use QStyledItemDelegate

      I don't know from the image posted above where the view is

      the view is what determines how items are laid out, in your image it's a simple QListView as all the items are placed one below the other

      what model used?

      Whatever you want. the model is what holds your strings of chat plus some more metatdata (sender name, date and time of the message, if it was received by the other party or not).
      As always I suggest you use QStandardItemModel through the QAbstractItemModel interface (i.e. declare your model as something like QAbstractItemModel* model = new QStandardItemModel;). This lets you use the convenience of that model and also always allow you to use any other model in the future changing just 1 line of code.

      to have a result like the one of whatsapp posted in the image above

      Welcome to hell. You need to reimplement QStyledItemDelegate::paint. Anything beyond this point is just untested brainstorming:

      You can use QTextLayout to help you figure out the size of the bubble, paint it and paint the text finally you have to figure out size, position and paint of the time and the tickmarks. QFontMetrics should help there

      "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

      1 Reply Last reply
      3
      • E EL-jos

        Hello everyone,
        I make a thcatt(messenger) software and I have reached the stage of viewing the message with emoji and I don't know how to do it, here is an image as an example of a conversation:
        0_1541700001616_Capture.PNG

        so @SGaist offered me to use the QItemDelegate, since I didn't know how to do it so @mrjj gave me a link to follow a training on the QItemDelegate and I finished the training well but it doesn't really help me to solve my problem because I don't know from the image posted above where the view is? what model used? to have a result like the one of whatsapp posted in the image above

        Thank you for your help in advance

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @EL-jos
        You may find it a lot to take in, but @VRonin's post above is really useful to read through carefully and work through bit by bit.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          EL-jos
          wrote on last edited by
          #4

          Yes thank you very much @VRonin's for your answers as @jonB said it, I have to read it little by little while doing exercises to understand well but if you also have tutorials on QStyledItemDelegate::paint you can give me it because it will also help me

          VRoninV 1 Reply Last reply
          0
          • E EL-jos

            Yes thank you very much @VRonin's for your answers as @jonB said it, I have to read it little by little while doing exercises to understand well but if you also have tutorials on QStyledItemDelegate::paint you can give me it because it will also help me

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

            @EL-jos said in Which Widget is used with the ItemDelegate?:

            if you also have tutorials on QStyledItemDelegate::paint

            There's http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html but it's nowhere near the level of complexity required to layout that bubble

            "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

            1 Reply Last reply
            0
            • E Offline
              E Offline
              EL-jos
              wrote on last edited by
              #6

              Thanks a lot @VRonin's for the link but I still leave the topic open because in case of blocking I'll just come back here and post my problem to get your help

              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