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. Setting default color for brush
Qt 6.11 is out! See what's new in the release blog

Setting default color for brush

Scheduled Pinned Locked Moved General and Desktop
17 Posts 2 Posters 7.3k 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    do you mean QBrush? Because it's not clear whats the base class type of "paint".

    QBrush has an "constructor":http://qt-project.org/doc/qt-4.8/qbrush.html#QBrush-3 which accepts a QColor as parameter.

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thescouse
      wrote on last edited by
      #3

      It's QPainter .

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #4

        ok but a QPainter doesn't have a method called setPenColor(). So i guess you have implemented it?!
        If so it should be analog for the brush.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thescouse
          wrote on last edited by
          #5

          I created that function:
          void paint::setPenColor(const QColor &newColor)
          //! [5] //! [6]
          {
          myPenColor = newColor;
          }

          Parts declared in paint.h header file{
          void setPenColor(const QColor &newColor);

          QColor myPenColor;}

          These are the extra info. related to the function

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thescouse
            wrote on last edited by
            #6

            Any help now? How to set the default color for the pen?

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #7

              QPainter::setPen(QColor) and QPainter::setBrush(QColor)

              but i don't know what you actually are doing. :)

              you defined the method as
              @paint::setPenColor(const QColor &newColor)@
              but using it as
              @painter->setPenColor(255,255,255);@

              This can't work.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • T Offline
                T Offline
                thescouse
                wrote on last edited by
                #8

                okay...so what should I do?

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #9

                  use the 2 QPainter methods i've posted.

                  and as i said, the code you've posted isn't clear to me, so i can't help you with the information you have posted so far.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    thescouse
                    wrote on last edited by
                    #10

                    hmm...okay...so like I have to choose the white color. How to use the setpen method?
                    what's the exact code for that...
                    (sorry for asking the exact thing...usually i would have worked it out, but i have to show this in half an hour...so, i think u can understand the desperation) :P

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #11

                      @
                      painter; //your QPainter instance

                      painter->setPen( QColor(Qt::white) );
                      painter->setBrush( QColor(Qt::white) );
                      @

                      good luck!

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        thescouse
                        wrote on last edited by
                        #12

                        thanks...;)

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          thescouse
                          wrote on last edited by
                          #13

                          okay..I implemented what you said.
                          But now it shows these errors:
                          invalid use of incomplete type 'struct ImageViewer'
                          &
                          forward declaration of 'struct ImageViewer'

                          before this it didn't show these...what's the problem?

                          1 Reply Last reply
                          0
                          • raven-worxR Offline
                            raven-worxR Offline
                            raven-worx
                            Moderators
                            wrote on last edited by
                            #14

                            post the complete code please of the affected class/file.

                            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                            If you have a question please use the forum so others can benefit from the solution in the future

                            1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              thescouse
                              wrote on last edited by
                              #15

                              hey..no need just found out the problem.
                              just slight error.
                              Thanks...it works :)

                              1 Reply Last reply
                              0
                              • raven-worxR Offline
                                raven-worxR Offline
                                raven-worx
                                Moderators
                                wrote on last edited by
                                #16

                                good to hear.

                                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                If you have a question please use the forum so others can benefit from the solution in the future

                                1 Reply Last reply
                                0
                                • T Offline
                                  T Offline
                                  thescouse
                                  wrote on last edited by
                                  #17

                                  thanks...:)

                                  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