PDA

View Full Version : scroll in QFrame



jackajack01
2nd August 2012, 20:34
hi

I have a QFrame inside this I have a QHBoxLayout within this HBox I have several QVBoxLayout containing (among other things) a QGraphicsView. the problem is that when I add many VBox scrollBar but does not appear that overlays the images.

How I can do to bring up the scroll of the HBox or QFrame?

thanks

jesse_mark
2nd August 2012, 20:44
if i understand you issue right, all u need is to use QScrollArea not a Qfram.

jackajack01
2nd August 2012, 21:09
try using the ScrollArea, but the result was the same. Although I say explicitly showing the scrolling so

scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn );

but the bar is turned off.

Added after 4 minutes:

no way to add a scrollbar to a QHBoxLayout?? the problem is that this object will grow dynamically during execution.

jesse_mark
2nd August 2012, 23:37
the QcrollArea suppose to show the scroll bar .... are you sure you are adding your objects to the scrollArea ??

play with the scorllArea and put punch of objects in it and make it small so u can see, when the scroll will show

Added after 8 minutes:

the bar will not show on unless you have more objects than what the area can display.

jackajack01
3rd August 2012, 14:32
I know that, if the object is within the area is small scroll the scroll bar will not display.

within the ScrollArea I have a QHBoxLayout, which grows dynamically. within this HBox I can have one or more QGraphicsView, each QGraphicsView has its own scroll bar. The problem is that instead of scroll bar appears when there are many within the HBox QGraphicsView overlap the Qgraphics.

so I have the class constructor

ViewGraphics::ViewGraphics()
{
scroll = new QScrollArea();
layerH = new QHBoxLayout(this);
layerV = new QVBoxLayout(this);
toolBar = new QToolBar("graphic");

button = new QAction(QIcon(":/images/registro.ico"),tr("&Example"), this);
button->setStatusTip(tr("Change palette"));
connect(button, SIGNAL(triggered()), this, SLOT(ChangePalette()));

toolBar->addAction(button);

layerV->addWidget(toolBar);

layerV->addLayout(layerH);

scroll->setLayout(layerV);

this->setWidget(scroll);
}

and in another method insert elements in the layerH

This class inherits from QDockWidget

jesse_mark
3rd August 2012, 16:07
sorry, but i didn't understand what you are trying to do here....

so, why don't you try using the Qt Designer in Qt Creator, then run to see if the result is what you want.

then if you don't want to use the Qt Designer to create your form, go to the build directory and you will find Ui.XXXX.h and see how you should layout your elements

jackajack01
3rd August 2012, 17:56
the problem is that apparently the layout is at the bottom of ScrollArea, because it looks like the image is:

8092

jackajack01
9th August 2012, 15:51
I solved the problem as follows:

instead of putting the layout directly in the ScrollArea, create a QWidget on which I put the layout QWidget and this is what I put in the ScrollArea.

the code is as follows:

ViewGraphics::ViewGraphics()
{
scroll = new QScrollArea(this);
widget = new QWidget(scroll);
layerH = new QHBoxLayout();
layerV = new QVBoxLayout(widget);
toolBar = new QToolBar("graphic");

button = new QAction(QIcon(":/images/registro.ico"),tr("&Example"), this);
button->setStatusTip(tr("Change palette"));
connect(button, SIGNAL(triggered()), this, SLOT(ChangePalette()));

toolBar->addAction(button);

layerV->addWidget(toolBar);

layerV->addLayout(layerH);

widget->setLayout(layerV);

scroll->setWidget(widget);

this->setWidget(scroll);

}