[Qt-interest] how to add a scrollBar in QTabWidget
Sujan Dasmahapatra
sujan.dasmahapatra at gmail.com
Thu Jul 14 15:02:03 CEST 2011
Hi Samuel
In the last example if I add a layout in widget and then put all the buttons
in the layout then those buttons are being resized to fit the screen. I dont
want that, They should appear as it is and a scroll bar should come. I am
not getting any scrollbar in the tabwidget.
Can u tell me anyone whats wrong in this code below.. If I omit setWidget()
then I can see those buttons..... But there is not scrollbar coming... and
if I keep setWidget() then not buttons are visible..... I dont want to use
any layout. Is it possible to show those buttons and scrollbar to appear
anyways. . Plese give me some suggestions any one. Thanks sujan
check it...
///////////////////////////////
class TabWidget : public QTabWidget
{
Q_OBJECT
public:
TabWidget();
~TabWidget();
public:
QStringList name;
QList<QScrollArea *> areas;
QList<QWidget *> pages;
};
//////////////////////////////
TabWidget::TabWdiget()
{
for(int i=0; i<10; i++)
{
name.append("Page" + QString::number(i+1));
areas..append(new QScrollArea(this));
pages.append(new QWidget(area.last()));
area.last()->setWdiegt(pages.last());
addTab(areas.last(),name.last());
int coordx = 20;
int coordy = 20;
int w = 50;
int h = 25;
int incre = 0;
for(int j=0; j<20; j++)
{
buttons..append(new QPushButton("button " +
QString::number(j+1), pages.last()));
buttons..last()->setGeometry(coordx,coordy+incre,w,h);
buttons.last()->show();
incre += h+10;
}
}
}
/////////////////////////////
On Thu, Jul 14, 2011 at 4:59 PM, Samuel Gaist <samuel.gaist at edeltech.ch>wrote:
> Hi,
>
> Use the doc :
> http://doc.qt.nokia.com/4.7/qscrollarea.html#details
>
> And i still recommend the use of a layout.
>
> Samuel
>
> On 14 juil. 2011, at 12:12, Sujan Dasmahapatra wrote:
>
> >
> > Hi Samuel
> >
> > Let us not discuss about complex set of controls. But my requirement is
> very simple, I want scrollBar in QTabWidget. By default there is not scroll
> bar in the QTabWidget. How can I achive a scroll bar in each of the pages of
> QTabWidget. Please give me some suggestions. Thanks sujan
> >
> > I have created some 10 tabs using
> > QWidget *page = new QWidget(this);
> > QString name = "OnlyPage";
> > addTab(page,name);
> >
> > now there are some buttons I created which goes down to be invisible. So
> I want a scroll bar....Let me know if you understand my problem. thanks
> sujan
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Jul 14, 2011 at 12:30 PM, Samuel Gaist <samuel.gaist at edeltech.ch>
> wrote:
> > No it's not, but without a layout you have to manage positioning, size
> etc... all by yourself.
> > You can also write your own derivative of QLayout.
> >
> > What is a complex set of controls for you ?
> >
> > Samuel
> >
> > On 13 juil. 2011, at 15:16, Sujan Dasmahapatra wrote:
> >
> > > I want to ask onething that this layout creation is not mandatory right
> ? If I have a complex set of controls then layout creation is not possible.
> Still my controls should pop up in the pages.at(i) and I should be able
> to see them. Any comments, Thanks sujan
> > >
> > >
> > > Kind Regards,
> > >
> > >
> > > Sujan Dasmahapatra
> > > Project Leader, Aero Group
> > > Aero Group
> > > Tel +91 80 66470248
> > > Mob
> > > sdh at lmwindpower.com
> > >
> > > LM Wind Power Blades
> > > lmwindpower.com
> > >
> > > Together we capture the wind to power a cleaner world
> > >
> > >
> > > This e-mail and any attachments are confidential. If you are not the
> named or intended recipient, please notify the sender immediately and do not
> disclose the contents to any other person, use it for any purpose, or store
> or copy the information in any medium. Any unauthorized disclosure, use or
> storage is prohibited and might be unlawful.
> > >
> > > -----Original Message-----
> > > From: Samuel Gaist [mailto:samuel.gaist at edeltech.ch]
> > > Sent: Wednesday, July 13, 2011 6:34 PM
> > > To: Sujan Dasmahapatra
> > > Subject: Re: [Qt-interest] how to add a scrollBar in QTabWidget
> > >
> > > 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
> > >
> > > _______________________________________________
> > > Qt-interest mailing list
> > > Qt-interest at qt.nokia.com
> > > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at qt.nokia.com
> > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> >
> >
> >
> > --
> > Thanks & Regards
> > Sujan Dasmahapatra
> > B.E. (Aeronautics)
> > Bangalore, India
> > Ph:91-9900839788
> > mail id : sujan.dasmahapatra at gmail.com
> > yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
> > icq # 556023244
> > skype:sujan.dasmahapatra at skyepe.com
> > msn: sujan.dasmahapatra at hotmail.com
> >
> >
> >
> > --
> > Thanks & Regards
> > Sujan Dasmahapatra
> > B.E. (Aeronautics)
> > Bangalore, India
> > Ph:91-9900839788
> > mail id : sujan.dasmahapatra at gmail.com
> > yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
> > icq # 556023244
> > skype:sujan.dasmahapatra at skyepe.com
> > msn: sujan.dasmahapatra at hotmail.com
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at qt.nokia.com
> > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
--
Thanks & Regards
Sujan Dasmahapatra
B.E. (Aeronautics)
Bangalore, India
Ph:91-9900839788
mail id : sujan.dasmahapatra at gmail.com
yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
icq # 556023244
skype:sujan.dasmahapatra at skyepe.com
msn: sujan.dasmahapatra at hotmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110714/a7c54ccc/attachment.html
More information about the Qt-interest-old
mailing list