Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Utilizing Multiple ui files in the Same Class

    General and Desktop
    2
    3
    6514
    Loading More Posts
    • 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.
    • DarthFutuza
      DarthFutuza last edited by

      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 Reply Quote 0
      • D
        dbzhang800 last edited by

        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 Reply Quote 0
        • DarthFutuza
          DarthFutuza last edited by

          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 Reply Quote 0
          • First post
            Last post