[Qt-interest] Detect clicks over certain areas of a bitmap

Tom Panning lurchvt at gmail.com
Fri Dec 19 23:07:19 CET 2008


On Thu, Dec 18, 2008 at 4:33 PM, Sergio Salas
<sergio.salas.bernal at gmail.com> wrote:
> Hello,
>
> I have just begun with Qt libraries and I need some help. I want to
> detect when the user click over certain areas of a bitmap, but I don't
> know the best way to do it.
>
> My first idea was to use a QButtonGroup with transparent QPushButtons
> placed over the bitmap, and connect the signal "clicked(int id)" to one
> of my functions. This way I could know when the user has clicked over
> the bitmap and in wich area. Unfortunately, I couldn't make a button
> transparent.
>
> Is there any way to get a transparent button or define one area of a
> bitmap and detect when the user click on it?
>

If you're new to Qt and want to do more "specialized" things (as
opposed to just having standard forms with line edits and buttons) I
would highly recommend the book "C++ GUI Programming with Qt 4".
Chapter 5 is about custom widgets and describes a situation similar to
yours (and describes a solution similar to Oliver's).

Tom

Disclaimer: I don't have any relation to the book's authors or
publishing company, but I wish it had been available when I started
learning Qt.



More information about the Qt-interest-old mailing list