Lykurg
10th September 2006, 15:08
Hi,
I have following class:
#ifndef NORMALSEARCHWIDGET_H
#define NORMALSEARCHWIDGET_H
#include <QWidget>
#include <QBoxLayout>
class listBrowserWidget;
class normalSearchWidget : public QWidget
{
Q_OBJECT
public:
normalSearchWidget(QWidget *parent = 0);
~normalSearchWidget();
public slots:
void setLbTbDirection ( QBoxLayout::Direction direction );
private:
listBrowserWidget *lbw1;
listBrowserWidget *lbw2;
QBoxLayout *layout;
};
#endif
#include <QBoxLayout>
#include "normalsearchwidget.h"
#include "listbrowserwidget.h"
normalSearchWidget::normalSearchWidget(QWidget *parent)
: QWidget(parent)
{
layout = new QBoxLayout( QBoxLayout::TopToBottom );
layout->setMargin( 0 );
layout->setSpacing( 2 );
listBrowserWidget *lbw1 = new listBrowserWidget();
listBrowserWidget *lbw2 = new listBrowserWidget();
layout->addWidget(lbw1);
layout->addWidget(lbw2);
this->setLayout( layout );
// Next line works ( same line as in setLbTbDirection(QBoxLayout::Direction direction) )
lbw1->setDirection( QBoxLayout::TopToBottom );
// with this line I get and segmentation fault!
setLbTbDirection( QBoxLayout::TopToBottom );
}
normalSearchWidget::~normalSearchWidget()
{}
void normalSearchWidget::setLbTbDirection ( QBoxLayout::Direction direction )
{
lbw1->setDirection( QBoxLayout::TopToBottom );
}
As discribed in the commentar, I don't anderstand, why a statement in the constructor works and in a lokal function it causes an segFault. The function itself, without the line, works also perfekt.
I yet have deleted all generatet files, and have recompiled my program, but the error is still there.
Thanks for help,
Lykurg
I have following class:
#ifndef NORMALSEARCHWIDGET_H
#define NORMALSEARCHWIDGET_H
#include <QWidget>
#include <QBoxLayout>
class listBrowserWidget;
class normalSearchWidget : public QWidget
{
Q_OBJECT
public:
normalSearchWidget(QWidget *parent = 0);
~normalSearchWidget();
public slots:
void setLbTbDirection ( QBoxLayout::Direction direction );
private:
listBrowserWidget *lbw1;
listBrowserWidget *lbw2;
QBoxLayout *layout;
};
#endif
#include <QBoxLayout>
#include "normalsearchwidget.h"
#include "listbrowserwidget.h"
normalSearchWidget::normalSearchWidget(QWidget *parent)
: QWidget(parent)
{
layout = new QBoxLayout( QBoxLayout::TopToBottom );
layout->setMargin( 0 );
layout->setSpacing( 2 );
listBrowserWidget *lbw1 = new listBrowserWidget();
listBrowserWidget *lbw2 = new listBrowserWidget();
layout->addWidget(lbw1);
layout->addWidget(lbw2);
this->setLayout( layout );
// Next line works ( same line as in setLbTbDirection(QBoxLayout::Direction direction) )
lbw1->setDirection( QBoxLayout::TopToBottom );
// with this line I get and segmentation fault!
setLbTbDirection( QBoxLayout::TopToBottom );
}
normalSearchWidget::~normalSearchWidget()
{}
void normalSearchWidget::setLbTbDirection ( QBoxLayout::Direction direction )
{
lbw1->setDirection( QBoxLayout::TopToBottom );
}
As discribed in the commentar, I don't anderstand, why a statement in the constructor works and in a lokal function it causes an segFault. The function itself, without the line, works also perfekt.
I yet have deleted all generatet files, and have recompiled my program, but the error is still there.
Thanks for help,
Lykurg