[Qt-interest] Making a table in a form the same width as the tab within which the form is placed
Robert Wood
robert.wood at apostrophe.co.uk
Sun Mar 14 16:39:10 CET 2010
In case anyone else comes across this, it turns out it's not that
difficult to do once I'd actually sussed out the command.
1. Create the new tab.
tabCount = mainTab->count();
qwVector.insert(tabCount,newTab);
mainTab->addTab(qwVector[tabCount],tabName);
mainTab->setCurrentIndex(tabCount);
2. Create a QHBoxLayout and attach it to the tab:
quint8 i = (mainTab->count() - 1);
QHBoxLayout *hBLO;
hBLO = new QHBoxLayout(qwVector[i]);
3. Once the new widget has been chosen, stick it in the QHBoxLayout. For
example:
table_contents *ein = new table_contents(qwVector[i],&db);
hBLO->addWidget(ein);
ein->show();
This does exactly what I want. The important thing was the QHBoxLayout.
On 13/03/10 17:06, Robert Wood wrote:
> I have an application where, in the main window, I have a dock widget
> which is anchored to the the left of the window, then I have placed a
> QTabWidget and made that expand to the size the user makes the main
> window by using setCentralWidget.
>
> I am then allowing the user to open different tabs and have different
> forms I have created put within each new tab. Now, in some of the forms
> that are placed within the tabs, I have tables which can have many
> columns. What I would like to do is have the width of the table expand
> and contract to the width of its containing tab as the user expands and
> contracts the width of the main window, therefore expanding and
> contracting the QTabWidget. I guess I am looking for the equivalent of
> setCentralWidget within the form (which is really a QWidget isn't it?)
> which is placed within the QTabWidget. Would that be right?
More information about the Qt-interest-old
mailing list