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. Triangle button - Geometry
QtWS25 Last Chance

Triangle button - Geometry

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.8k 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.
  • G Offline
    G Offline
    goocreations
    wrote on last edited by
    #1

    If created my custom buttons (inhereting from QPushButton). I've redefined the paintEvent to draw a triangle
    Now I have put the buttons next to each other, as shown here: "http://i54.tinypic.com/2z81efa.png":http://i54.tinypic.com/2z81efa.png

    My problem now is that I want to create a bunch of functions for clicked() mouseOver(), etc..
    But since the only way of doing this is to call the setGeometry() of the button and setGeometry() only takes a rectangle, the two buttons' geometry overlap.
    This means when my mouse moves over button2, the mouseOver() event never occurs since button1's geometry overlaps with with button2's geometry.

    I don't think it is possible to setGeomtry() with a polygon, or is it?
    Is there maybe any other way to accomplish this (that each triangle button can receive their own event in this position and form)?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Geometry on widgets is always a rectangle.

      You maybe could go with "QGraphicsView":http://doc.trolltech.com/4.7-snapshot/qgraphicsview.html and "QGraphicsItem":http://doc.trolltech.com/4.7-snapshot/qgraphicsitem.html which happens to support a "shape()":http://doc.trolltech.com/4.7-snapshot/qgraphicsitem.html#shape

      Or you create your own QWidget derived class, do the painting (which you already implemented) and handle the mouse events yourself. In that way you would have two buttons in one widget. Don't know if that would be of any use for you...

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goocreations
        wrote on last edited by
        #3

        Thanks, I will look at QGraphicsView.

        The second option you mentioned wouldn't work so well, my buttons can actually be any shape/polygon in any position

        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