Is your form named "CalculatorForm" (check the objectName property)?
Is your form named "CalculatorForm" (check the objectName property)?
the .ui file is saved as calculatorform.ui and the objectName property is set to the value Form
Regards
Sajjad
Thanks Jacek,
Extending a component through the use of inheritance is functional.
Now i have another issue regarding layout designing within Qt designer.
I created a form widget and created some components(button, combo boxes)
within the form and grouped them together in a grid layout.
Then i inherit that class generated by qt compiler and incorporated a RenderArea class where i can draw different primitives.
And creating another layout of grid layout type and then adding the render area as widget and the previous grid layout from the super class . The code snippet is as follows:
***************************''
//create the layout
QGridLayout *mainLayout = new QGridLayout;
//add the render area and the items that have been
//created with Qt Designer
mainLayout->addWidget(renderArea,0,0);
mainLayout->addLayout(ui.gridLayout,1,0);
setLayout(mainLayout);
*****************************''
The code compiled fine. But while running having the following error:
QLayout::addChildLayout: layout "gridLayout" already has a parent
Segmentation fault
Any Idea?
Regards
Sajjad
If you want to add a widget to the layout created with Qt Designer, it is easier to use the widget promotion mechanism.
http://doc.trolltech.com/4.4/designe...moting-widgets
Hello jacek,
I have gone through the material that you have sent with the link.
"To add a placeholder, select an object of a suitable base class and choose Promote to ... from the form's context menu. After entering the class name and header file in the lower part of the dialog, choose Add. The placeholder class will now appear along with the base class in the upper list. Click the Promote button to accept this choice."
I did not understand exactly how do i do that. If you please take a look at the attached png file, you will see that a form with widgets already in the layout.
What i want to do is :
1. Create a main layout and add the layout that you see in the form to the main layout.
2. Create the RenderArea that is the subclass of the QWidget and add that to the main layout.
So in that case which one is the place-holder that i should promote to?
While designing the form i have the form itself and the other widgets set in a grid layout , what is not there is the RenderArea and it is the subclass of QWidget and how do i choose the place-holder for the RenderArea and who would be the place-holder?
Regards
Sajjad
Thanks jacek,
Drag a QWidget within the Qt Designer and promoted it to the custom class that i have made.
Now i have almost the same error:
QLayout::addChildLayout: layout "gridLayout" already has a parent
Segmentation fault
Another forum said something related to that
"If you want to create a sub-layout (i.e. you want to add it to another
layout), then you have to create it WITHOUT a parent. Just use the
constructor of QLayout without a parent.
Only add a parent (namely the top widget) for a top level layout (i.e. the
main layout of a widget).
"
How do i do that from within the Qt Designer?
In my case the gridLayout is the sub layout. and i have to instantiate that without a parent.
Regards
Sajjad
The problem is that you try to add a layout to a form that already has a layout. Qt doesn't like this.
Either drag a layout from the toolbox just as if it was a widget or select few widgets and click the "Lay out in ..." action (you should see a red rectangle around those widgets).
dosto.walla (15th September 2008)
Hello jacek,
i am still having the same error. So i am attaching the related files.
I hope that you can make some time out of your busy schedule.
Regards
Sajjad
Hello jacek,
I have attached some screen-shots of the things you have recommended to do to avoid the error:
The image that is attached first shows the following:
1. All the toolbars that are arranged in a grid layout.
2. The rectangle box beside that is a QWidget that i have dragged into the form.
The second image shows how i promoted the custom class RenderArea.h to one of the place-holders(QWidget)
The i compiled them ,but while running i have the runtime error as follows:
QLayout::addChildLayout: layout "gridLayout" already has a parent
Segmentation fault
It says that the gridLayout already has a parent
i followed you suggestion
"Either drag a layout from the toolbox just as if it was a widget or select few widgets and click the "Lay out in ..." action (you should see a red rectangle around those widgets)."
I followed the one in the bold mark. And you can see that in the attached images as well.
Regards
Sajjad
Hi jacek,
Sorry that i could not attach the second image with the previous post
Here i am sending the second image
Regards
Sajjad
Bookmarks