i put a GroupBox inside my tabWidget and added lots of widgets in my groupBox, now how can i enable the scrollBar in my groupBox so that it i can view all my widgets.
or is there any other container that has a scrollBar that can be enable.
baray98
i put a GroupBox inside my tabWidget and added lots of widgets in my groupBox, now how can i enable the scrollBar in my groupBox so that it i can view all my widgets.
or is there any other container that has a scrollBar that can be enable.
baray98
Sounds like you have this kind of structure:
[html]
QGroupBox
|-ChildWidget1
|-ChildWidget2
|- ...
[/html]
Make it like this:
[html]
QGroupBox
|-QScrollArea
|-ChildWidget1
|-ChildWidget2
|-...
[/html]
J-P Nurmi
baray98 (17th September 2007)
i still can not make it to scroll here my code below
(this is at the constructor and this class inherits QGroupBox)
Qt Code:
scroll->setWidget(frame); frame->setLayout(mainLayout); mainLayout->addStretch(); topLayout->addWidget(frame); setLayout(topLayout);To copy to clipboard, switch view to plain text mode
i have a method called addInfo below
Qt Code:
{ infoLayout->addWidget(lblValue); leValue->setReadOnly ( true ); leValue->setAlignment(Qt::AlignRight); infoLayout->addWidget(leValue); infoLayout->addStretch(); mainLayout->insertLayout(mainLayout->count()-1,infoLayout); }To copy to clipboard, switch view to plain text mode
its all a mess please help
baray98
my full cocstructor looks like this
Qt Code:
{ //ctor scroll->setWidget(frame); frame->setLayout(mainLayout); mainLayout->addStretch(); topLayout->addWidget(frame); setLayout(topLayout); }To copy to clipboard, switch view to plain text mode
I am afraid the first code snippet you posted makes no freakin' sense .
General QScrollArea usage: all widgets that you want to be contained by then scroll area have to be contained by a top level(container) widget. This container has to be added to the scroll area.
So, here's an example. You can add this to your custom group box constructor:
Qt Code:
topLayout->addWidget(scrollArea); setLayout(topLayout); //Now, for the group box holder->setLayout(mainLayout); scrollArea->setWidget(holder);To copy to clipboard, switch view to plain text mode
Now you can add widgets to holder widget, just like you did in the second code snippet, with the exception that you must not pass 'this' as parent for the new widgets, but the holder widget.
baray98 (17th September 2007)
marcel, thanks for the quick reply .. but when i changed my code below all i see i a big widget inside my groupBox. I did not see any of my text edits and labels and there was no scroll bar either.
Qt Code:
{ //ctor topLayout->addWidget(scrollArea); setLayout(topLayout); //Now, for the group box holder->setLayout(mainLayout); mainLayout->addStretch(); scrollArea->setWidget(holder); } FrameInfo::~FrameInfo() { //dtor } { infoLayout->addWidget(lblValue); leValue->setReadOnly ( true ); leValue->setAlignment(Qt::AlignRight); infoLayout->addWidget(leValue); infoLayout->addStretch(); mainLayout->insertLayout(mainLayout->count()-1,infoLayout); }To copy to clipboard, switch view to plain text mode
this really confusing me
baray98
Try this:
Qt Code:
{ QHBoxLayout* infoLayout = new QHBoxLayout; // (holder); <-- remove parent, holder already has a layout installed (produces warning) ... holder->adjustSize(); // <-- add this as last statement of addInfo() }To copy to clipboard, switch view to plain text mode
J-P Nurmi
baray98 (17th September 2007)
thanks!!! a lot it work now
Bookmarks