Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QGraphicsItem Border

    General and Desktop
    qimage qgraphicsitem qgraphicsview stylesheet
    3
    3
    2153
    Loading More Posts
    • 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.
    • S
      sunil.nair last edited by

      Hi, I have a QImage as a QGraphicsItem inside a QGraphicsView. I want to apply a 2 px border to this image(graphics item.). Is there a way to apply a stylesheet to this QGraphicsItem?

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @sunil.nair last edited by raven-worx

        @sunil.nair said in QGraphicsItem Border:

        Is there a way to apply a stylesheet to this QGraphicsItem?

        no. QSS is only available to QtWidgets
        You have to draw the border yourself (maybe place the pixmap item inside a custom QGraphicsRectItem - which draws the border).

        --- 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 Reply Quote 1
        • m.sue
          m.sue last edited by

          Hi,
          you should be able to do so by overriding the QRectF boundingRect() const function. Just call the base function to get the current rect., and return rect.adjusted(2,2,2,2).
          -Michael.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post