
Originally Posted by
purplecoast
Thanks. I actually do need them because in my case I have a GUI-based library that another GUI application uses. And the GUI app needs to call method of the QtDesigner UI objects from the base library.
Either the file should be regenerated from the ui file or you should expose the objects in a proper header file as part of your class's interface. Doing it the way you are trying to do is not a pretty design.
// header file
namespace Ui {
class MyWidget;
}
public:
MyWidget();
~MyWidget();
private:
Ui::MyWidget *ui;
};
// header file
namespace Ui {
class MyWidget;
}
class MyWidget : public QWidget {
public:
MyWidget();
~MyWidget();
QPushButton *button() const; // expose object
private:
Ui::MyWidget *ui;
};
To copy to clipboard, switch view to plain text mode
// implementation file
#include "headerfile"
#include "ui_mywidget.h"
ui = new Ui::MyWidget;
ui->setupUi(this);
}
MyWidget::~MyWidget() { delete ui; }
QPushButton* MyWIdget
::button() const { return ui
->button;
}
// implementation file
#include "headerfile"
#include "ui_mywidget.h"
MyWidget::MyWidget() : QWidget() {
ui = new Ui::MyWidget;
ui->setupUi(this);
}
MyWidget::~MyWidget() { delete ui; }
QPushButton* MyWIdget::button() const { return ui->button; }
To copy to clipboard, switch view to plain text mode
Bookmarks