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. Replace QTreeView::branch using pixmap ?
QtWS25 Last Chance

Replace QTreeView::branch using pixmap ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpixmapqtreeviewqpainter
12 Posts 4 Posters 1.2k 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 3 Nov 2019, 18:10 last edited by
    #1

    Hey

    I did some drawing in my qt app and I would like to use them as a QTreeView branch for my qtree view. How can I set branch to use my pixmap?

    TIA.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Nov 2019, 19:10 last edited by
      #2

      Hi,

      One possible way is through Qt's stylesheet system.

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

      D 1 Reply Last reply 4 Nov 2019, 07:22
      1
      • S SGaist
        3 Nov 2019, 19:10

        Hi,

        One possible way is through Qt's stylesheet system.

        D Offline
        D Offline
        Dariusz
        wrote on 4 Nov 2019, 07:22 last edited by
        #3

        @SGaist Yes, but how can I pass QPixmap to a widget.setStyle(""" style < pass pixmap?"""); ?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Nov 2019, 07:59 last edited by
          #4

          I currently don't know if it's possible to have them inline in the style sheet. I would guess using base64 encoding but that's really only that, a guess. What you can do is to save your drawings as .png files in a suitable folder provided by QStandardPaths and then use them in the style sheet.

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

          D 1 Reply Last reply 4 Nov 2019, 11:14
          4
          • S SGaist
            4 Nov 2019, 07:59

            I currently don't know if it's possible to have them inline in the style sheet. I would guess using base64 encoding but that's really only that, a guess. What you can do is to save your drawings as .png files in a suitable folder provided by QStandardPaths and then use them in the style sheet.

            D Offline
            D Offline
            Dariusz
            wrote on 4 Nov 2019, 11:14 last edited by
            #5

            @SGaist Quite suprising that we can't use QPixmap/QImage in stylesheet I must say... :- ) Looks like I will have to create my pixmap on app start, save to hdd, path to them in style, load style, then delete files.... fun ! :- )

            M 1 Reply Last reply 4 Nov 2019, 11:27
            0
            • D Dariusz
              4 Nov 2019, 11:14

              @SGaist Quite suprising that we can't use QPixmap/QImage in stylesheet I must say... :- ) Looks like I will have to create my pixmap on app start, save to hdd, path to them in style, load style, then delete files.... fun ! :- )

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 4 Nov 2019, 11:27 last edited by
              #6

              @Dariusz
              Hi
              Well you can use images from a resource file which is super handy.
              Then you need zero code to have them at funtime and you can ref them directly in style sheet

              D 1 Reply Last reply 4 Nov 2019, 12:47
              1
              • M mrjj
                4 Nov 2019, 11:27

                @Dariusz
                Hi
                Well you can use images from a resource file which is super handy.
                Then you need zero code to have them at funtime and you can ref them directly in style sheet

                D Offline
                D Offline
                Dariusz
                wrote on 4 Nov 2019, 12:47 last edited by
                #7

                @mrjj How can I add images to resources at runtime? I want to change the branch indicator to have the color that user wishes to do here.

                J M 2 Replies Last reply 4 Nov 2019, 12:48
                0
                • D Dariusz
                  4 Nov 2019, 12:47

                  @mrjj How can I add images to resources at runtime? I want to change the branch indicator to have the color that user wishes to do here.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 4 Nov 2019, 12:48 last edited by
                  #8

                  @Dariusz @SGaist already suggested a way

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Dariusz
                    4 Nov 2019, 12:47

                    @mrjj How can I add images to resources at runtime? I want to change the branch indicator to have the color that user wishes to do here.

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 4 Nov 2019, 13:07 last edited by
                    #9

                    @Dariusz
                    Hi
                    Ok so it has to be 100% dynamical
                    so you create the actual pixmap runtime? it can be any color ?
                    Else you can just have the various versions in the resource file.

                    You dont add anything to the resource file at runtime as its compiled into the exe ! :)

                    D 1 Reply Last reply 4 Nov 2019, 13:25
                    0
                    • M mrjj
                      4 Nov 2019, 13:07

                      @Dariusz
                      Hi
                      Ok so it has to be 100% dynamical
                      so you create the actual pixmap runtime? it can be any color ?
                      Else you can just have the various versions in the resource file.

                      You dont add anything to the resource file at runtime as its compiled into the exe ! :)

                      D Offline
                      D Offline
                      Dariusz
                      wrote on 4 Nov 2019, 13:25 last edited by
                      #10

                      @mrjj Yep its dynamic and user can pick color, in future hell be able to draw his own shapes/icons and all that. But for now its pre-drawn using custom colors.

                      As far as I can tell I have to save to hdd and load it up via stylesheet & path...

                      Bummer :- )

                      M 1 Reply Last reply 4 Nov 2019, 13:44
                      0
                      • D Dariusz
                        4 Nov 2019, 13:25

                        @mrjj Yep its dynamic and user can pick color, in future hell be able to draw his own shapes/icons and all that. But for now its pre-drawn using custom colors.

                        As far as I can tell I have to save to hdd and load it up via stylesheet & path...

                        Bummer :- )

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 4 Nov 2019, 13:44 last edited by
                        #11

                        @Dariusz
                        Hi
                        Ok, fully dynamic.
                        Ok in that case, the resource file is a no go and
                        @SGaist advice seems the best option/maybe only option.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 4 Nov 2019, 14:35 last edited by
                          #12

                          Then maybe QTreeView::drawBranches is what you are looking for.

                          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

                          9/12

                          4 Nov 2019, 13:07

                          • Login

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