Thanks, when doing this I get a pointer back rather than 0, however the application still crashes when trying to add my QScrollArea to the layout. Any hints?
EDIT: First time I tried layout() on the central widget I got a valid pointer, but consecutive runs yield a 0 pointer like previously :S
Main
int main(int arg_count, char **arg_list)
{
mainwindow ui;
ui.show();
return juliet.exec();
}
int main(int arg_count, char **arg_list)
{
QApplication juliet(arg_count, arg_list);
QApplication::setStyle(new QPlastiqueStyle);
mainwindow ui;
ui.show();
return juliet.exec();
}
To copy to clipboard, switch view to plain text mode
Class header
{
Q_OBJECT
public:
mainwindow();
...
};
class mainwindow:public QMainWindow
{
Q_OBJECT
public:
mainwindow();
QScrollArea *render_window;
QLabel *label_render;
QGridLayout *render_layout;
...
};
To copy to clipboard, switch view to plain text mode
Class implementation
mainwindow::mainwindow()
{
QFile file(":/interface/juliet.ui");
file.
open(QFile::ReadOnly);
QWidget *central
= loader.
load(&file
);
setCentralWidget(central);
file.close();
label_render = findChild<QLabel*>("label_render");
render_layout = qobject_cast<QGridLayout*>(central->layout());
pixmap.fill(Qt::black);
label_render->setPixmap(pixmap);
label_render->setAlignment(Qt::AlignCenter);
render_window->setWidget(label_render);
render_window->setWidgetResizable(true);
render_window->setFocusPolicy(Qt::NoFocus);
render_window->installEventFilter(this);
render_layout->addWidget(render_window, 0, 0, 1, 4); // <-- Application crash
}
mainwindow::mainwindow()
{
QUiLoader loader;
QFile file(":/interface/juliet.ui");
file.open(QFile::ReadOnly);
QWidget *central = loader.load(&file);
setCentralWidget(central);
file.close();
label_render = findChild<QLabel*>("label_render");
render_layout = qobject_cast<QGridLayout*>(central->layout());
render_window = new QScrollArea;
QPixmap pixmap(200, 200);
pixmap.fill(Qt::black);
label_render->setPixmap(pixmap);
label_render->setAlignment(Qt::AlignCenter);
render_window->setWidget(label_render);
render_window->setWidgetResizable(true);
render_window->setFocusPolicy(Qt::NoFocus);
render_window->installEventFilter(this);
render_layout->addWidget(render_window, 0, 0, 1, 4); // <-- Application crash
QMetaObject::connectSlotsByName(this);
}
To copy to clipboard, switch view to plain text mode
Bookmarks