Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why i can't change color of QString?
Qt 6.12 LTS is out! See what's new in the release blog

Why i can't change color of QString?

Scheduled Pinned Locked Moved Unsolved General and Desktop
46 Posts 7 Posters 41.4k 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by VRonin
    #18

    I made a proxy model to support roles in models that don't https://github.com/VSRonin/QtModelUtilities the class is called RoleMaskProxyModel. Here is an example that uses it to colour QStringListModel: https://github.com/VSRonin/QtModelUtilities/blob/1.0.0/examples/exam_RoleMaskProxyModel/exam_rolemaskhighlight.cpp

    Hopefully I'll eventually find the time to complete adding that class to Qt: https://codereview.qt-project.org/#/c/245572/

    "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

    EngelardE 1 Reply Last reply
    2
    • VRoninV VRonin

      I made a proxy model to support roles in models that don't https://github.com/VSRonin/QtModelUtilities the class is called RoleMaskProxyModel. Here is an example that uses it to colour QStringListModel: https://github.com/VSRonin/QtModelUtilities/blob/1.0.0/examples/exam_RoleMaskProxyModel/exam_rolemaskhighlight.cpp

      Hopefully I'll eventually find the time to complete adding that class to Qt: https://codereview.qt-project.org/#/c/245572/

      EngelardE Offline
      EngelardE Offline
      Engelard
      wrote on last edited by Engelard
      #19

      @VRonin Looks very interesting.
      I downloaded your rolemaskproxymodel and classes related to it(whole src directory), but when i tried to Run i got such strange stuff:

      0_1553856387649_sdfsdf.jpg
      Oh and don't look at first two errors, they unrelated completelly, it appears when i swap compiler to Release mode, did'nt figure out what it is yet.

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

        If you just copy-paste the code you have to add DEFINES += MODELUTILITIES_STATIC to your .pro file

        "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

        EngelardE 1 Reply Last reply
        1
        • VRoninV VRonin

          If you just copy-paste the code you have to add DEFINES += MODELUTILITIES_STATIC to your .pro file

          EngelardE Offline
          EngelardE Offline
          Engelard
          wrote on last edited by
          #21

          @VRonin ye, first time tried to use someone elses code :D
          Now i downloaded whole stuff like a normal person. Look at my post with screenshot above.

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

            Exact same answer.
            There's a section in the readme that explains how to use the library: https://vsronin.github.io/QtModelUtilities/md__i_n_s_t_a_l_l.html

            "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

            EngelardE 1 Reply Last reply
            1
            • VRoninV VRonin

              Exact same answer.
              There's a section in the readme that explains how to use the library: https://vsronin.github.io/QtModelUtilities/md__i_n_s_t_a_l_l.html

              EngelardE Offline
              EngelardE Offline
              Engelard
              wrote on last edited by
              #23

              @VRonin I added that macro to .pro file and nothing changed, same 4 errors.

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

                You have to manually click on build-> rerun qmake every time you change something in the .pro file

                "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

                EngelardE 1 Reply Last reply
                1
                • VRoninV VRonin

                  You have to manually click on build-> rerun qmake every time you change something in the .pro file

                  EngelardE Offline
                  EngelardE Offline
                  Engelard
                  wrote on last edited by
                  #25

                  @VRonin of course i did that. Still same 4 errors

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

                    let's do it manually then: remove all the MODELUTILITIES_EXPORT

                    "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

                    EngelardE 1 Reply Last reply
                    0
                    • VRoninV VRonin

                      let's do it manually then: remove all the MODELUTILITIES_EXPORT

                      EngelardE Offline
                      EngelardE Offline
                      Engelard
                      wrote on last edited by
                      #27

                      @VRonin said in Why i can't change color of QString?:

                      MODELUTILITIES_EXPORT

                      How? you mean edit your src files?

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

                        yep!
                        All DEFINES += MODELUTILITIES_STATIC does is transforming MODELUTILITIES_EXPORT into an empty string. if that doesn't work then just manually do a find and replace

                        "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

                        EngelardE 1 Reply Last reply
                        0
                        • VRoninV VRonin

                          yep!
                          All DEFINES += MODELUTILITIES_STATIC does is transforming MODELUTILITIES_EXPORT into an empty string. if that doesn't work then just manually do a find and replace

                          EngelardE Offline
                          EngelardE Offline
                          Engelard
                          wrote on last edited by
                          #29

                          @VRonin oKay. In what files that stuff which i should to replace? I only can assume that such stuff MODELUTILITIES_EXPORT is macro, so it must be in some .h files, right?

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

                            Actually, it probably just easier to replace the entire modelutilities_global.h with

                            #ifndef modelutilities_global_h__
                            #define modelutilities_global_h__
                            #define MODELUTILITIES_EXPORT
                            #endif // modelutilities_global_h__
                            

                            "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

                            EngelardE 1 Reply Last reply
                            0
                            • VRoninV VRonin

                              Actually, it probably just easier to replace the entire modelutilities_global.h with

                              #ifndef modelutilities_global_h__
                              #define modelutilities_global_h__
                              #define MODELUTILITIES_EXPORT
                              #endif // modelutilities_global_h__
                              
                              EngelardE Offline
                              EngelardE Offline
                              Engelard
                              wrote on last edited by
                              #31

                              @VRonin Done. But still that four errors(

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #32

                                Hi,

                                Do you mean the symbol missing error ?

                                Did you build @VRonin library statically ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                EngelardE 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Hi,

                                  Do you mean the symbol missing error ?

                                  Did you build @VRonin library statically ?

                                  EngelardE Offline
                                  EngelardE Offline
                                  Engelard
                                  wrote on last edited by
                                  #33

                                  @SGaist said in Why i can't change color of QString?:

                                  Did you build @VRonin library statically ?

                                  0_1553942357112_statt.jpg

                                  @SGaist said in Why i can't change color of QString?:

                                  Do you mean the symbol missing error ?

                                  0_1553942408999_errr.jpg

                                  I tried multiple times: Build>Clean all>Run qmake>Rebuild all.

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #34

                                    Do you have a .dll file matching that library ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    EngelardE 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      Do you have a .dll file matching that library ?

                                      EngelardE Offline
                                      EngelardE Offline
                                      Engelard
                                      wrote on last edited by
                                      #35

                                      @SGaist What .dll? I just downloaded src folder, did'nt saw any dll in there

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #36

                                        The .dll if you have built @VRonin's library.

                                        Otherwise, how did you integrate it in your application ?

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        EngelardE 1 Reply Last reply
                                        1
                                        • SGaistS SGaist

                                          The .dll if you have built @VRonin's library.

                                          Otherwise, how did you integrate it in your application ?

                                          EngelardE Offline
                                          EngelardE Offline
                                          Engelard
                                          wrote on last edited by
                                          #37

                                          @SGaist said in Why i can't change color of QString?:

                                          Otherwise, how did you integrate it in your application ?

                                          Just included rolemaskproxymodel.h and start using that stuff what he showed in example

                                          mrjjM VRoninV 2 Replies Last reply
                                          0

                                          • Login

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