Results 1 to 5 of 5

Thread: Dynamic Handling of Hundreds of UI elements

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2015
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Dynamic Handling of Hundreds of UI elements

    Hi
    you could find all QDoubleSpinBox in mainwindow and then loop them
    and do the setting of filter on each.

    QList<QDoubleSpinBox *> spins = MainWindow->findChildren<QDoubleSpinBox *>();

    http://doc.qt.io/qt-5/qobject.html#findChildren
    Last edited by Metavoid; 8th February 2016 at 08:19.

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

    Default Re: Dynamic Handling of Hundreds of UI elements

    Derive from QDoubleSpinBox, implement the customization, use your spinbox instead of the default one.

    Then you don't have to do anything in MainWindow::MainWindow() other then calling setupUi();

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Dynamic Handling of Hundreds of UI elements

    Quote Originally Posted by anda_skoa View Post
    Derive from QDoubleSpinBox, implement the customization, use your spinbox instead of the default one.

    Then you don't have to do anything in MainWindow::MainWindow() other then calling setupUi();

    Cheers,
    _
    maybe you can go into greater detail

    <-----n00b

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

    Default Re: Dynamic Handling of Hundreds of UI elements

    1) derive a custom class from QDoubleSpinBox
    2) implement the event filter in that class and install it on "this" and on the line edit (you have direct access to the line edit through a protected method declared in the base class)
    3) Use designer's "promote widget" function to replace the QDoubleSpinBoxes with your class.

    Cheers,
    _

Similar Threads

  1. Change state on dynamic elements.
    By Binpix in forum Qt Quick
    Replies: 5
    Last Post: 1st October 2013, 23:20
  2. Replies: 0
    Last Post: 29th March 2012, 19:56
  3. Replies: 3
    Last Post: 26th July 2011, 19:11
  4. Replies: 1
    Last Post: 20th January 2011, 17:17
  5. Qt and C++ dynamic memory handling...
    By giowck in forum Newbie
    Replies: 6
    Last Post: 18th November 2009, 19:50

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
  •  
Qt is a trademark of The Qt Company.