Results 1 to 2 of 2

Thread: Access to UI elements

  1. #1
    Join Date
    Jan 2017
    Location
    Vigo
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Access to UI elements

    Hi everyone!

    I am attemptting to access to elements of mainwindow.ui (it would be named ui elements? ).

    I have two sample of use of this elements.

    First work fine but in case of comboBox It doen't work.

    Could you help me?

    Qt Code:
    1. QString def_fileGbxml = ui->lineEditFile->text();
    2.  
    3. QComboBox cb_tipoEdificio = this->ui->comboBox_1
    To copy to clipboard, switch view to plain text mode 

    How can define it to use in my mainwindow.cpp. I want to load it from file of data.

    I have data on file like that:

    Qt Code:
    1. constructionIdRefs:
    2. cons-1
    3. cons-2
    4. cons-3
    5. cons-4
    6. cons-5
    7. cons-6
    8. ***************
    9. openingTypes:
    10. FixedWindow
    11. NonSlidingDoor
    12. end1;
    13. end2;
    To copy to clipboard, switch view to plain text mode 

    I can write file like I want. Do you recommend another organization of data??

    On the other hand. I read about define manual ComboBox and Label but in this way I can't view it in main window.

    For example:

    Qt Code:
    1. QGridLayout *layoutPrincipal = new QGridLayout();
    2. layoutPrincipal->addWidget(new QLabel("Latitud"),0,0);
    3. latitud = new QLineEdit();
    4. layoutPrincipal->addWidget(latitud,0,1);
    5. layoutPrincipal->addWidget(new QLabel("Longitud"),1,0);
    6. longitud = new QLineEdit();
    7. layoutPrincipal->addWidget(longitud,1,1);
    8.  
    9. getLocation = new QPushButton("Get Position");
    10. layoutPrincipal->addWidget(getLocation,3,0,1,2);
    11.  
    12. valores_combo << "primero" << "segundo" << "tercero";
    13. combo_buildings = new QComboBox();
    14.  
    15. combo_buildings->addItems(valores_combo);
    16.  
    17. this->setWindowTitle("Config of initial values of gbxml");
    18. this->setLayout(layoutPrincipal);
    To copy to clipboard, switch view to plain text mode 

    Is there any way to view this elements in mainwindow.ui?

    It is possible a mix of both?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Models On-line

    First work fine but in case of comboBox It doen't work.
    Yo need to use a pointer:
    Qt Code:
    1. QComboBox *cb_tipoEdificio = this->ui->comboBox_1
    To copy to clipboard, switch view to plain text mode 

    The rest of your post is just very hard to understand.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Access to UI elements from another class c++
    By nasil122002 in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2013, 15:43
  2. Access elements of the xml-file
    By 8Observer8 in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2013, 18:27
  3. SVG: access coordinates of elements
    By bmpix in forum Qt Programming
    Replies: 5
    Last Post: 31st August 2012, 23:29
  4. Ready to use QML elements
    By .:saeed:. in forum Qt Quick
    Replies: 0
    Last Post: 22nd February 2011, 16:25
  5. Replies: 4
    Last Post: 6th August 2009, 06:12

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.