[Qt-interest] how to add a scrollBar in QTabWidget
Samuel Gaist
samuel.gaist at edeltech.ch
Wed Jul 13 15:04:49 CEST 2011
Hi,
This is not a complete complete compilable example but anyway here is the source of your current problem:
you need to use layouts, try with my little modification in your code.
You might also want to go through http://doc.qt.nokia.com/4.7/widgets-tutorial.html
Hope this helps
Samuel
On 13 juil. 2011, at 14:40, Sujan Dasmahapatra wrote:
> The complete example is this Samuel. Please check below.
>
> class TabWidget: public QTabWidget
> {
> Q_OBJECT;
> public:
> TabWidget();
> ~TabWidget();
> private:
> QStringList names;
> QList<QWidget *> pages;
> QList<QScrollArea *> areas;
> };
>
> TabWidget::TabWidget() {
> For(int i=0; i<10; i++)
> {
> names.append("Page " + QString::number(i+1));
> areas.append(new QScrollArea(this));
> pages.append(new QWidget(areas.at(i)));
> areas.at(i)->setWidget(pages.at(i));
> addTab(areas.at(i),names.at(i)); //names is QStringList of 10 strings.
>
>
> // Now I'll create the contents in the pages.
>
QVBoxLayout *layout = new QVBoxLayout(pages.at[i]);
> QList <QPushButton *> buttons;
> for(int j=0; j<20; j++)
> {
> buttons.append(new QPushButton(tr("MyButton %1").arg(j)));
layout->addWidget(buttons.last());
> }
>
> }
> }
>
>
> With these I am creating 20 buttons in each page. But I cannot see a single button with this. Any help would be highly appreciated.
>
>
> Kind Regards,
>
>
> Sujan Dasmahapatra
More information about the Qt-interest-old
mailing list