Results 1 to 2 of 2

Thread: How can I use events for widgets that are not visible by default?

  1. #1
    Join Date
    Sep 2012
    Location
    Iran
    Posts
    34
    Thanks
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default How can I use events for widgets that are not visible by default?

    Hello everyone.
    I am trying to use lets say click event on a QLabel ( or a QSpinBox, when a user presses `Enter`, it e.g executes a method etc).
    I know in the hierarchy it gets it (from base widget class? )
    Now I have read everywhere that whenever I want to use events that are not visible by default, I have to make a custom label class from inhering from QLabel, and then override that specific event.
    This is cumbersome, and time consuming, suppose I have different widgets on my form, and for each of them I have to do this, and If the application has a complex GUI, I will not be able to use QtCreators designer which mostly I use, and I will be stuck with the hand-code everything!

    Is there a workaround this limitation in Qt? why do you do when you encounter situations like this?
    Is it not possible for the QtCreator to list the inherited events (signals) as well, and let the user use them ? would it not make it better ?
    I would be grateful to know how I can get around this. I am stuck with simplistic GUI, that if I want to make it more complex, it makes me rewrite everything almost from scratch !

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How can I use events for widgets that are not visible by default?

    Quote Originally Posted by Hossein View Post
    suppose I have different widgets on my form, and for each of them I have to do this, and If the application has a complex GUI, I will not be able to use QtCreators designer which mostly I use, and I will be stuck with the hand-code everything!
    You can always use your own widget subclasses in designer, that is what its "promote widget" functionality is for.

    But you could also look into using an event filter: QObject::eventFilter.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Hossein (24th October 2015)

Similar Threads

  1. Force all widgets in a QGridLayout to be visible
    By SeanM in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2014, 23:07
  2. Replies: 3
    Last Post: 30th July 2012, 12:54
  3. Replies: 4
    Last Post: 27th April 2012, 11:12
  4. Key shortcuts for not visible widgets
    By trskel in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2007, 11:02
  5. All widgets are visible in QStackedWidget
    By YuriyRusinov in forum Qt Programming
    Replies: 14
    Last Post: 22nd March 2007, 13:02

Tags for this Thread

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.