Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Utilizing Multiple ui files in the Same Class
QtWS25 Last Chance

Utilizing Multiple ui files in the Same Class

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DarthFutuzaD Offline
    DarthFutuzaD Offline
    DarthFutuza
    wrote on last edited by
    #1

    Hi there, so I have a custom widget ui and a custom dialog ui that I've created in Qt Designer. And I'm trying to initialize and create both of them using the same class. This is what I have:

    @class SettingDialogues :public QWidget
    {
    Q_OBJECT

    public:

    //constructor, deconstructor
    SettingDialogues(QWidget *parent = 0, Qt::WindowFlags f = 0 );
    SettingDialogues(QDialog *parent = 0);
    ~SettingDialogues();

    //functions

    private:
    Ui::MainSettings *ui_main; //dynamic pointer object's for ui
    Ui::SubSettings *ui_sub; //<- want to declare another one, not working though@

    And in my cpp file I have something like this:

    @SettingDialogues::SettingDialogues(QWidget *parent, Qt::WindowFlags f)
    :QWidget(parent),
    //initialize the ui
    ui_main(new Ui::MainSettings)
    {
    ui_main->setupUi(this);
    }

    SettingDialogues::SettingDialogues(QDialog *parent)
    :QWidget(parent),
    //initialize the ui
    ui_sub(new Ui::SubSettings)
    {
    ui_sub->setupUi(this); //<-Compiler doesn't like this. :(
    }

    //deconstructor
    SettingDialogues::~SettingDialogues()
    {
    delete ui_main;
    }@

    I was hoping I didn't need to create a whole 2nd class for the SubSettings dialog box. Help?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      All the usages of ui files can be found here: http://qt-project.org/doc/qt-5.0/qtdesigner/designer-using-a-ui-file.html

      1 Reply Last reply
      0
      • DarthFutuzaD Offline
        DarthFutuzaD Offline
        DarthFutuza
        wrote on last edited by
        #3

        Thanks, didn't quite have the information I was looking for, but I managed to figure it out with some trial and error. I ended up just creating another class as I cannot have the declaration of my class have this:
        @
        class SettingDialogues :public QWidget
        {
        Q_OBJECT@

        And still work with QDialog, I have to pick one apparently.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved