Hello.
I have a custom widget class ( inherited from QWidget ) and an UI class made in Qt Designer and attached to mainwindow widget by ..->setupUi(…) method.
In the UI class I’ve put QWidget in Qt Designer ( empty region ) and I need to put inside it my custom widget class ( inherited from QWidget ).
I tried to make this by setting parent when construction custom widget class:
...
MainWindow::MainWindow(QWidget *parent
) : mc(new Ui::MainControl),intern(new Ui::Internal)
{
mc->setupUi(this);
intern->setupUi(this->mc->centralwidget);
//constructing image viewing:
image_preview=new ImageView();
image_preview->setParent(intern->widget_image);
...
...
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
mc(new Ui::MainControl),intern(new Ui::Internal)
{
mc->setupUi(this);
intern->setupUi(this->mc->centralwidget);
//constructing image viewing:
image_preview=new ImageView();
image_preview->setParent(intern->widget_image);
...
To copy to clipboard, switch view to plain text mode
But I get segmentation fault on Linux when I run the program. When I comment the last row:
//image_preview->setParent(intern->widget_image);
//image_preview->setParent(intern->widget_image);
To copy to clipboard, switch view to plain text mode
There is no seg. fault but image_preview is not added to intern UI class.
Does anybody know how to add the custom widget image_preview to the UI class member intern->widget_image , so the widget will be seen and active on the UI?
Thanks a lot for help.
Bookmarks