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 ?
Forum Updated to NodeBB v4.3 + New Features

Replace QTreeView::branch using pixmap ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpixmapqtreeviewqpainter
12 Posts 4 Posters 1.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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on 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
    1
    • SGaistS SGaist

      Hi,

      One possible way is through Qt's stylesheet system.

      D Offline
      D Offline
      Dariusz
      wrote on last edited by
      #3

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

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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
        • SGaistS SGaist

          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 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 ! :- )

          mrjjM 1 Reply Last reply
          0
          • D Dariusz

            @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 ! :- )

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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
            1
            • mrjjM mrjj

              @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 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.

              jsulmJ mrjjM 2 Replies Last reply
              0
              • D Dariusz

                @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.

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on 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

                  @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.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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
                  0
                  • mrjjM mrjj

                    @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 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 :- )

                    mrjjM 1 Reply Last reply
                    0
                    • D Dariusz

                      @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 :- )

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 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
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 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

                        • Login

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