PDA

View Full Version : Segment fault



kenchan
5th December 2012, 13:32
Hi All,


use Qt Creator 4.7 , didn't use designer, a dockwidget has several filters, Segment fault when complied,codes as below:

dockWidget = new QDockWidget(this);
dockWidget->setObjectName(QString::fromUtf8("dockWidget"));

dockWidgetContents = new QWidget();
dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents"));

gridLayout = new QGridLayout(dockWidgetContents);
gridLayout->setSpacing(6);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));

horizontalLayout_2 = new QHBoxLayout();//Segment fault
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));

time_dateEdit = new QDateEdit(dockWidgetContents);
time_dateEdit->setObjectName(QString::fromUtf8("time_dateEdit"));

horizontalLayout_2->addWidget(time_dateEdit);

horizontalSpacer_2 = new QSpacerItem(18, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

horizontalLayout_2->addItem(horizontalSpacer_2);

lcdNumber = new QLCDNumber(dockWidgetContents);
lcdNumber->setObjectName(QString::fromUtf8("lcdNumber"));
horizontalLayout_2->addWidget(lcdNumber);


gridLayout->addLayout(horizontalLayout_2, 0, 0, 1, 1);

horizontalLayout = new QHBoxLayout();//segment fault
horizontalLayout->setSpacing(6);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalSlider = new QSlider(dockWidgetContents);
horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider"));
horizontalSlider->setOrientation(Qt::Horizontal);

horizontalLayout->addWidget(horizontalSlider);

openBtn = new QPushButton(dockWidgetContents);
openBtn->setObjectName(QString::fromUtf8("openfileBtn"));

horizontalLayout->addWidget(openfileBtn);

preBtn = new QPushButton(dockWidgetContents);
preBtn->setObjectName(QString::fromUtf8("preBtn"));

horizontalLayout->addWidget(preBtn);

gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);

dockWidget->setWidget(dockWidgetContents);


Please give me any advice!

TKS.

ken

amleto
5th December 2012, 13:44
explain exactly what you have done for all qt installations - what compiler you used.

what compiler are you using now?

What do you do to compile your programs? What is your PATH like?

kenchan
5th December 2012, 13:50
if the code changed as below, the layout is didn't i want to layout.
horizontalLayout = new QHBoxLayout(dockWidgetContents);
horizontalLayout = new QHBoxLayout(dockWidgetContents);

and if the code changed as below, segment fault also.
horizontalLayout = new QHBoxLayout(dockWidget );
horizontalLayout = new QHBoxLayout(dockWidget );

Hi amleto,
i use mingw32 to compile my program.

amleto
5th December 2012, 13:57
hi, please read my post, above, and answer the questions. Thanks.

also state how you build your application e.g. pro file.

kenchan
5th December 2012, 14:16
Hi amleto,
i use mingw32 complier.
complied success if i use designer to build the project which has several filters in dockwidget,
but i want to write codes to build the project to complete what i want, so i consulted ui_mainwindow.h as above.

thanks.

ken

amleto
5th December 2012, 14:56
It seems you have some difficulty in understanding my questions? You have not answered all of them.

Qt designer is not even an IDE - it can't even start a compiler so you are not using designer to build your code.

wysota
5th December 2012, 16:20
Hi All,


use Qt Creator 4.7 , didn't use designer, a dockwidget has several filters, Segment fault when complied,codes as below:

dockWidget = new QDockWidget(this);
dockWidget->setObjectName(QString::fromUtf8("dockWidget"));

dockWidgetContents = new QWidget();
dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents"));

gridLayout = new QGridLayout(dockWidgetContents);
gridLayout->setSpacing(6);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));

horizontalLayout_2 = new QHBoxLayout();//Segment fault
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));

time_dateEdit = new QDateEdit(dockWidgetContents);
time_dateEdit->setObjectName(QString::fromUtf8("time_dateEdit"));

horizontalLayout_2->addWidget(time_dateEdit);

horizontalSpacer_2 = new QSpacerItem(18, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

horizontalLayout_2->addItem(horizontalSpacer_2);

lcdNumber = new QLCDNumber(dockWidgetContents);
lcdNumber->setObjectName(QString::fromUtf8("lcdNumber"));
horizontalLayout_2->addWidget(lcdNumber);


gridLayout->addLayout(horizontalLayout_2, 0, 0, 1, 1);

horizontalLayout = new QHBoxLayout();//segment fault
horizontalLayout->setSpacing(6);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalSlider = new QSlider(dockWidgetContents);
horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider"));
horizontalSlider->setOrientation(Qt::Horizontal);

horizontalLayout->addWidget(horizontalSlider);

openBtn = new QPushButton(dockWidgetContents);
openBtn->setObjectName(QString::fromUtf8("openfileBtn"));

horizontalLayout->addWidget(openfileBtn);

preBtn = new QPushButton(dockWidgetContents);
preBtn->setObjectName(QString::fromUtf8("preBtn"));

horizontalLayout->addWidget(preBtn);

gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);

dockWidget->setWidget(dockWidgetContents);


Please give me any advice!

TKS.

ken

So... you got two segmentation faults at once? :D

amleto
5th December 2012, 20:47
I didn't even want to go there! :eek:

kenchan
6th December 2012, 00:40
Hi wysota,
segment fault when app quit, when i debugged, complier prompted segment fault at "QHBoxLayout".

Hi amleto,

my English is not good, i'm sorry i don't catch all your meaning.

TKS.

ken

wysota
6th December 2012, 00:45
If you are getting segmentation faults upon quitting the app, the crash is caused by destructors, not by a constructor. Post the backtrace from your debugger.

kenchan
6th December 2012, 00:57
Hi wysota,

Good morning!

thank you for your response.

when i debugged. information reference to segmentation faults as below:

MessageBox:
The inferior stopped because it received a signal from the Operating System.
Signal name:SIGSEGV
Signal meaning:Segmentation fault

debugger:
Stopped:Segmentation fault by signal SIGSEGV

Level Function file line address
0 ~QBoxLayoutItem qboxlayout.cpp 72 0x0112ab69



if i add QWidget to QHBoxLayout(). complied success. see as below:
horizontalLayout_2 = new QHBoxLayout(dockWidgetContents );
horizontalLayout = new QHBoxLayout(dockWidgetContents );

wysota
6th December 2012, 02:23
Please post the full backtrace, not only the top frame.

kenchan
6th December 2012, 12:44
Hi All,

i have handled it. thank you very much.

ken

amleto
6th December 2012, 12:50
What was the solution? If someone googles their own problem and finds this thread, they will be frustrated to see 'solved!', but nobody posted the solution...

kenchan
25th December 2012, 11:30
i used QGridLayout instead of QHBoxLayout, so that the problem have solved!