Results 1 to 4 of 4

Thread: Can I make a QWidget "pressable" without being a QPushButton?

  1. #1
    Join Date
    Mar 2011
    Posts
    82
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Can I make a QWidget "pressable" without being a QPushButton?

    I have a topbar on my aplication and I want that, on "click" it performs a certain action. The thing is that my topbar is not a button, so I don't know how to proceed with this requirement.

    My question then, is this:

    Can you make it so that when you click on a QWidget it still registers said click?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Can I make a QWidget "pressable" without being a QPushButton?


  3. #3
    Join Date
    Mar 2011
    Posts
    82
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can I make a QWidget "pressable" without being a QPushButton?

    As the object's method?

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Can I make a QWidget "pressable" without being a QPushButton?

    Reimplement the mousePressEvent() in the "topbar" class and do all the "click" stuff there.
    Another way is to install eventFilter on the topbar button, if you don't want / can't subclass.

Similar Threads

  1. Replies: 0
    Last Post: 20th September 2010, 09:58
  2. Replies: 4
    Last Post: 18th April 2010, 00:37
  3. "new" + "delete" a QWidget and its children
    By vkincaid in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2010, 21:51
  4. "make install" and "make clean" on Windows for Qt
    By Berberis in forum Installation and Deployment
    Replies: 0
    Last Post: 29th November 2009, 23:02
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.