imperator
20th November 2009, 13:47
Hi
I get an segmentation fault when running a program I'm working on. From a button in a application based on QMainWindow, I open a new dialog to create a new activity. In the dialog I want to group the layout in group boxes.
// This is the constructor of the dialog
NewEvent::NewEvent(QWidget* parent) : QDialog(parent){
void createHorizontalGroupBox();
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(horizontalGroupBox);
setLayout(mainLayout);
...
}
void NewEvent::createHorizontalGroupBox(){
// horizontalGroupBox is declared in the h-file
horizontalGroupBox = new QGroupBox(tr("Some text"));
QHBoxLayout* layout = new QHBoxLayout;
QLabel* actLabel = new QLabel(tr("Some text"));
QLineEdit* actType = new QLineEdit;
layout->addWidget(actLabel);
layout->addWidget(actType);
horizontalGroupBox->setLayout(layout);
}
What happens is that when I click the button in the application the program quits and the "segmentation fault" is returned to the terminal.
If I remove/comment the mainLayout->addWidget(horizontalGroupBox); line, the program works the way I want.
What could this be down to?
Regards,
André
I get an segmentation fault when running a program I'm working on. From a button in a application based on QMainWindow, I open a new dialog to create a new activity. In the dialog I want to group the layout in group boxes.
// This is the constructor of the dialog
NewEvent::NewEvent(QWidget* parent) : QDialog(parent){
void createHorizontalGroupBox();
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(horizontalGroupBox);
setLayout(mainLayout);
...
}
void NewEvent::createHorizontalGroupBox(){
// horizontalGroupBox is declared in the h-file
horizontalGroupBox = new QGroupBox(tr("Some text"));
QHBoxLayout* layout = new QHBoxLayout;
QLabel* actLabel = new QLabel(tr("Some text"));
QLineEdit* actType = new QLineEdit;
layout->addWidget(actLabel);
layout->addWidget(actType);
horizontalGroupBox->setLayout(layout);
}
What happens is that when I click the button in the application the program quits and the "segmentation fault" is returned to the terminal.
If I remove/comment the mainLayout->addWidget(horizontalGroupBox); line, the program works the way I want.
What could this be down to?
Regards,
André