You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, October 31st 2011, 6:25pm

QVBoxLayout overlaping using Qpushbutton

I'm having problems to make my QVBoxLayout grow when using Qpushbuttons.

As I insert too many buttons the childrens are shrinking.
This behavior is not observed when i use Qt labels or QlineEdits.

I not sure what could be wrong but probably gonna be a undefined property.

I have already set mininiumsize to the children but doesn't work.
I also try set sizepolicy but the problem shouldn't be in the children but in the parent (QVboxLayout) that no grow.
This behavior make my buttons be overlapping.

Someone here can guess what could be happen?

Thanks.

2

Tuesday, November 1st 2011, 10:31am

Can you share your source code to help you for the same.

3

Tuesday, November 1st 2011, 11:46am

void cVPanelQt::AddComponent(cComponent * poComponent, bool bStretch, bool bAddAtBegin)
{
m_vecComponents.push_back(poComponent);

poComponent->SetParentContainer(this);
poComponent->SetVisible(poComponent->GetVisible());

QWidget * poChildWidget = static_cast<QWidget *>(poComponent->GetInnerComponent());

QBoxLayout * poLayout = dynamic_cast<QBoxLayout *>(m_poWidget->layout());
if (poLayout == 0)
return;

if (bStretch)
{
if (bInicialize == false)
{
bInicialize = true;
}
poChildWidget->setMinimumSize(QSize(0, 0));
poChildWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
else
{
if (bInicialize == false)
{
poLayout->addStretch(1);
bInicialize = true;
}
poChildWidget->setMinimumSize(QSize(0, poComponent->GetHeight()));
poChildWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
}

int iPos;
if (bAddAtBegin)
{
iPos = iAlignerPos;
iAlignerPos++;
}
else
{
iPos = iAlignerPos+1;
}

poLayout->insertWidget(iPos, poChildWidget);
cVPanelQt::AddButtonGroup(poChildWidget);
}
oximer has attached the following file:
  • ERROR QT1.jpeg (58.03 kB - 4 times downloaded - latest: Nov 5th 2011, 11:09pm)