Add push buttons dynamically to a widget
-
hi, some one please help me ..i have a widget in setup funtion...i want to add pushbuttons into that widget dynamically i written code like this
@
//in setup file
QWidget *analysis =new QWidget();
@@
// another file
for(.....){
.
.
QPushButton *pb=new QPushButtton("button");
layout->addWidget(pb);
}
analysis->setlayout(layout);@
i got seg fault can some one tell me where i done mistake -
Why haven't you set any parent of your QPushButton? Do you delete it manually?
Please have a look at "this basic tutorial how to use QPushButton":http://developer.qt.nokia.com/wiki/How_to_Use_QPushButton as it might help you.
-
-
It will be simpler to know where the segfault is generated. Try debugging each line or place some qDebug() in your code to understand at which line it happens. Usually the problem means you are trying to access an object you haven't created or you have already destroyed.
-
[quote author="fluca1978" date="1320838708"]It will be simpler to know where the segfault is generated. Try debugging each line or place some qDebug() in your code to understand at which line it happens. Usually the problem means you are trying to access an object you haven't created or you have already destroyed.[/quote]
Oh, exactly I've forgot about debug.
@sri438 just press F5 in QtCreator and you'll see where this error happens.