Project

General

Profile

Layout nightmare....

Added by Paul T... about 8 years ago

Hi all,

I'm having trouble understanding how layouts work...

Here is what I want to do :

Having my main page displaying some widgets on top from each other...

- First row = custom widgets in a WHBoxLayout

- Second row = some buttons

  • Third row = a custom widget (MyFileList) representing a list of custom widgets (MyFile)
    Let's say for the simplicity that MyFile is a PainteWidget which draws the File name in its own way.

According to the amout of files in the current directory, MyFileList adds or remove MyFile widgets and so has its height dynamic.

But I'm not able to have the Vertical Scroll bar displayed as my List goes big...

For the main page I did like this :

void WMainWindow::WMainWindow()

{

WFitLayout *v = new WFitLayout(this);

main_container = new WContainerWidget();

main_container->setOverflow(WContainerWidget::OverflowHidden, Horizontal);

main_container->setOverflow(WContainerWidget::OverflowAuto, Vertical);

v->addWidget(main_container);

AddBars(main_container);

AddButtons(main_container);

AddFileList(main_container);

}

void WMainWindow::AddVumeters(WContainerWidget *parentContainer)

{

WContainerWidget *bars_container;

WHBoxLayout *bars_layout;

bars_container = new WContainerWidget();

bars_layout = new WHBoxLayout();

bars_layout->addStretch(1);

for (int ii = 0; ii < NB_MAX_BARS; ii)

{

if (ii > 0 && ii%4 ==0)

{

bars_layout->addSpacing(10);

}

m_bars[ii] = new WMyBar();

m_bars[ii]->setMinimumSize(WLength::Auto,240);

m_bars[ii]->setMaximumSize(WLength::Auto,240);

m_bars[ii]->setInline(true);

bars_layout->addWidget(m_bars[ii]);

}

bars_layout->addStretch(1);

bars_container->setLayout(bars_layout);

parentContainer->addWidget(bars_container);

}

the same for AddButtons

For MyFileList

MyFileList::MyFileList(WContainerWidget *parent)

: WContainerWidget(parent)

{

m_pVBoxLayOut = new WVBoxLayout(this);

m_pContainer = new WContainerWidget();

m_pContainer->setLayout(m_pVBoxLayOut);

}

void MyFileList::SetFiles(std::vectorstd::string lczNames)

{

int nNbFiles = lczNames.size();

WText *pText;

for (int ii = 0 ; ii < nNbFiles ; ii)

{

pText = new WText(lczNames.at(ii));

m_pVBoxLayOut->addWidget(pText);

}

}