Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, June 2007
ScrollBar into tab question


Message 1 in thread

Hi There,

I hope that someone can pinpoint what is the problem here. Basically the
class would be an implementation of one tab on a QTabWidget. There should be
a QScrollArea on the tab containing a number of buttons. Somehow I cannot
make it work...

*.h
class CServerControlTab : public QWidget {
	Q_OBJECT

public:
	CServerControlTab(const QList<struct StructService> &List);

	QGridLayout *pMainLayout;

	QWidget *pConstructedParent;
	QScrollArea *pScrollArea;
};

*.cpp
CServerControlTab::CServerControlTab(const QList<struct StructService>
&List) {
	pScrollArea = new QScrollArea(this);
	pConstructedParent = new QWidget(pScrollArea);
	pScrollArea->setWidget(pConstructedParent);
	pMainLayout = new QGridLayout();
	pConstructedParent->setLayout(pMainLayout);

	QPushButton *pButton;
	for (int i = 0; i < 100; i++) {
		pButton = new QPushButton(QString("BUTTON_%1").arg(i));
		pMainLayout->addWidget(pButton);
	}
}

Thanks,
Sandor

--
 [ signature omitted ] 

Message 2 in thread

Hi Sandor,

Try adding buttons to pMainLayout first and then setting
pConstructedParent as the widget of scroll area afterwards.
pConstructedParent is resized according to its size hint by the time
it's set into the scroll area (unless the widget is made resizable
(QScrollArea::setWidgetResizable).

-- 
 [ signature omitted ] 

Message 3 in thread

Thanks, it works :)

-----Original Message-----
From: qt-interest-request@xxxxxxxxxxxxx
[mailto:qt-interest-request@xxxxxxxxxxxxx]On Behalf Of J-P Nurmi
Sent: 14/06/2007 14:26
To: Qt-interest
Subject: Re: ScrollBar into tab question


Hi Sandor,

Try adding buttons to pMainLayout first and then setting
pConstructedParent as the widget of scroll area afterwards.
pConstructedParent is resized according to its size hint by the time
it's set into the scroll area (unless the widget is made resizable
(QScrollArea::setWidgetResizable).

-- 
 [ signature omitted ] 

Message 4 in thread

This has been resolved, basically by putting setLayout to the end. This
thing starts to be difficult to me because now I have a different problem...
:( I will submit a separate ticket if I cannot resolve...

Sandor


-----Original Message-----
From: Hadas Sandor 
Sent: 14/06/2007 12:12
To: 'qt-interest@xxxxxxxxxxxxx'
Subject: ScrollBar into tab question


Hi There,

I hope that someone can pinpoint what is the problem here. Basically the
class would be an implementation of one tab on a QTabWidget. There should be
a QScrollArea on the tab containing a number of buttons. Somehow I cannot
make it work...

*.h
class CServerControlTab : public QWidget {
	Q_OBJECT

public:
	CServerControlTab(const QList<struct StructService> &List);

	QGridLayout *pMainLayout;

	QWidget *pConstructedParent;
	QScrollArea *pScrollArea;
};

*.cpp
CServerControlTab::CServerControlTab(const QList<struct StructService>
&List) {
	pScrollArea = new QScrollArea(this);
	pConstructedParent = new QWidget(pScrollArea);
	pScrollArea->setWidget(pConstructedParent);
	pMainLayout = new QGridLayout();
	pConstructedParent->setLayout(pMainLayout);

	QPushButton *pButton;
	for (int i = 0; i < 100; i++) {
		pButton = new QPushButton(QString("BUTTON_%1").arg(i));
		pMainLayout->addWidget(pButton);
	}
}

Thanks,
Sandor

--
 [ signature omitted ] 

Message 5 in thread

Pls. disregard this message, was sent by accident. Sorry.

-----Original Message-----
From: Hadas Sandor 
Sent: 14/06/2007 15:01
To: 'qt-interest@xxxxxxxxxxxxx'
Subject: RE: ScrollBar into tab question


This has been resolved, basically by putting setLayout to the end. This
thing starts to be difficult to me because now I have a different problem...
:( I will submit a separate ticket if I cannot resolve...

Sandor


-----Original Message-----
From: Hadas Sandor 
Sent: 14/06/2007 12:12
To: 'qt-interest@xxxxxxxxxxxxx'
Subject: ScrollBar into tab question


Hi There,

I hope that someone can pinpoint what is the problem here. Basically the
class would be an implementation of one tab on a QTabWidget. There should be
a QScrollArea on the tab containing a number of buttons. Somehow I cannot
make it work...

*.h
class CServerControlTab : public QWidget {
	Q_OBJECT

public:
	CServerControlTab(const QList<struct StructService> &List);

	QGridLayout *pMainLayout;

	QWidget *pConstructedParent;
	QScrollArea *pScrollArea;
};

*.cpp
CServerControlTab::CServerControlTab(const QList<struct StructService>
&List) {
	pScrollArea = new QScrollArea(this);
	pConstructedParent = new QWidget(pScrollArea);
	pScrollArea->setWidget(pConstructedParent);
	pMainLayout = new QGridLayout();
	pConstructedParent->setLayout(pMainLayout);

	QPushButton *pButton;
	for (int i = 0; i < 100; i++) {
		pButton = new QPushButton(QString("BUTTON_%1").arg(i));
		pMainLayout->addWidget(pButton);
	}
}

Thanks,
Sandor

--
 [ signature omitted ]