Results 1 to 2 of 2

Thread: dynamic Handling of Hundreds of UI elements

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

    Default dynamic Handling of Hundreds of UI elements

    Ok so here is what I've got... doubleSpinBox to doubleSpinBox_312. I made them all read only, I only want them the to be edited from within 1 dialog. Ive made one of them clickable through an eventFilter:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. ui->doubleSpinBox->installEventFilter(this);
    7. QObjectList o_list = ui->doubleSpinBox->children();
    8. for(int i = 0; i < o_list.length(); i++)
    9. {
    10. QLineEdit *cast = qobject_cast<QLineEdit*>(o_list[i]);
    11. if(cast)
    12. cast->installEventFilter(this);
    13. }
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    2. {
    3. if(event->type() == QEvent::MouseButtonPress)
    4. {
    5. Dialog mdialog;
    6. mdialog.setModal(true);
    7. mdialog.exec();
    8. }
    9. return false;
    10. }
    To copy to clipboard, switch view to plain text mode 

    I am wondering if its possible to automate this part

    Qt Code:
    1. ui->doubleSpinBox->installEventFilter(this);
    2. //~~~~~~~~^
    3. QObjectList o_list = ui->doubleSpinBox->children();
    4. // ~~~~~~~~^
    To copy to clipboard, switch view to plain text mode 

    and to make sure I can return a value to a function that corresponds to what spinbox has been selected so that the dialog can return the new value to the appropriate field.

    I really like the parameters and the look that the spinbox with no arrows gives so that's how I arrived at this juncture. Perhaps this more a C++ question than a Qt question, in any event IDK cause I'm a n00b.

    Qt 5

    preemptive thank you

  2. #2
    Join Date
    Mar 2015
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: dynamic Handling of Hundreds of UI elements


Similar Threads

  1. Dynamic Handling of Hundreds of UI elements
    By mrsurge in forum Newbie
    Replies: 4
    Last Post: 8th February 2016, 15:56
  2. Change state on dynamic elements.
    By Binpix in forum Qt Quick
    Replies: 5
    Last Post: 1st October 2013, 23:20
  3. Replies: 0
    Last Post: 29th March 2012, 19:56
  4. Replies: 3
    Last Post: 26th July 2011, 19:11
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.