Results 1 to 3 of 3

Thread: access to another ui object from mainwindow

  1. #1
    Join Date
    Jan 2016
    Posts
    7
    Thanks
    1
    Qt products
    Qt5

    Default access to another ui object from mainwindow

    Hi,
    I have a ui project that has mainwindow and another ui file. The another ui file has a combobox and i want to access it from mainwindow and i want to use its selected item in mainwindow. How can i do ?

  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: access to another ui object from mainwindow

    The class that uses the second UI just needs to provide a method that allows the main window to set a value on the combobox and a signal that forwards changes from he combobox to the outside of the second class.

    Qt Code:
    1. void SecondClass::setComboIndex(int index)
    2. {
    3. ui->comboBox->setCurrentIndex(index);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. SecondClass::SecondClass(QWidget *parent)
    2. : QWidget(parent)
    3. , ui(new Ui::SecondClass)
    4. {
    5. ui->setupUi(this);
    6. connect(ui->comboBox, &QComboBox::currentIndexChanged, this, &SecondClass::comboIndexChanged);
    7. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

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

    rapid84 (23rd January 2016)

  4. #3
    Join Date
    Jan 2016
    Posts
    7
    Thanks
    1
    Qt products
    Qt5

    Default Re: access to another ui object from mainwindow

    Thanks for reply.

Similar Threads

  1. Replies: 1
    Last Post: 1st April 2013, 04:24
  2. Access caller qml-Object from C++ Object
    By xdn in forum Qt Quick
    Replies: 5
    Last Post: 14th February 2013, 09:58
  3. Replies: 3
    Last Post: 12th April 2011, 10:58
  4. Replies: 4
    Last Post: 17th January 2011, 14:05
  5. How to access MainWindow objects.
    By Doug Broadwell in forum Newbie
    Replies: 1
    Last Post: 3rd November 2006, 10:03

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.