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. [Solved] Qt- Trouble changing color of Line
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt- Trouble changing color of Line

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 15.2k 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.
  • N Offline
    N Offline
    needhelp_gh
    wrote on last edited by
    #1

    Hi,

    I'm having trouble changing the color of Lines.

    I tried playing with the color & border color.

    None of them work when I preview or run my Gui.

    Any ideas? Thanks!!


    http://abstrusegoose.com/432

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      What kind of lines?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        You need to provide some code/image related to what you are trying to achieve.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          needhelp_gh
          wrote on last edited by
          #4

          "QLine":http://qt-project.org/doc/qt-4.8/qline.html


          http://abstrusegoose.com/432

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            Not sure how this has to be done as QLine does not inherits from QObject. However you can create your own class that inherits from QLine and QObject, Have a look "here":http://stackoverflow.com/questions/5270546/qt-qline-class-extension

            1 Reply Last reply
            0
            • N Offline
              N Offline
              needhelp_gh
              wrote on last edited by
              #6

              Great. Thanks, Sam!!


              http://abstrusegoose.com/432

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DerManu
                wrote on last edited by
                #7

                QLine is only the abstract concept of a line. Basically four integer values: x1,y1,x2,y2. The color, thickness, stroke etc. only comes in when a QPainter draws the line, in the QPen of the painter:
                @
                myPainter->setPen(QPen(Qt::red));
                myPainter->drawLine(myLine);
                @
                The line class is "dumb" (plain-old-data), it doesn't paint itself, it doesn't even know it's a line that can be painted, it just stores the abstract data that describes a line.

                Hence I'm not sure whether extending QLine is a good idea for what you want to do... What do you want to do? Maybe creating an own line class, which knows how to draw itself (i.e. has a ::draw(QPainter* painter) function) is the better way to go.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  veeraps
                  wrote on last edited by
                  #8

                  If it is going to be only Horizontal or Vertical lines, would suggest to consider QFrame class (Horizontal & Vertical lines comes with Qt Creator Toolbox).

                  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