#include <QApplication>
#include <QScrollArea>
#include <QFrame>
#include <QVBoxLayout>
#include <QDebug>
// the objects for the container
// should behave like pushbuttons, so horizontal resizig but fixed vertical size
// the vertical sizeHint is used for the max size but underrun for the min size
{
public:
{
this->updateGeometry();
}
virtual QSize sizeHint
() const {
}
virtual QSize minimumSizeHint
() const {
return this->sizeHint();
}
};
// hold the objects in a vertical layout
class Container
: public QFrame{
public:
Container
(QWidget *i_pParent
= NULL): {
for(int i = 0; i < 10; ++i)
{
this->layout()->addWidget(new Obj(this));
}
this->updateGeometry();
}
// never gets called
virtual QSize sizeHint
() const {
return QSize(1000,
1000);
}
// never gets called
virtual QSize minimumSizeHint
() const {
return this->sizeHint();
}
protected:
// never gets called
{
}
};
{
public:
Container *m_pContainer;
ScrollArea
(QWidget *i_pParent
= NULL): {
this->m_pContainer = new Container(this);
this->setViewport(this->m_pContainer);
this->setWidgetResizable(false);
// some messed up value "QRect(9,9 -18x-18)"
qDebug() << this->m_pContainer->layout()->contentsRect();
// QSize(1000,1000) as it ought to be
qDebug() << this->m_pContainer->size();
// false
qDebug() << this->widgetResizable();
}
};
int main(int argc, char **argv)
{
ScrollArea p_ScrollArea;
p_ScrollArea.resize(250, 250);
// viewport downsized, no scollbars
p_ScrollArea.show();
// QSize(230,230) - where did the QSize(1000, 1000) go?
// resizeEvent wasn't called
// and it shouldn't resize at all!
qDebug() << p_ScrollArea.m_pContainer->size();
return p_App.exec();
}
#include <QApplication>
#include <QScrollArea>
#include <QFrame>
#include <QVBoxLayout>
#include <QDebug>
// the objects for the container
// should behave like pushbuttons, so horizontal resizig but fixed vertical size
// the vertical sizeHint is used for the max size but underrun for the min size
class Obj : public QFrame
{
public:
Obj(QWidget *i_pParent = NULL):
QFrame(i_pParent)
{
this->setFrameStyle(QFrame::Raised | QFrame::Box);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
this->updateGeometry();
}
virtual QSize sizeHint() const
{
return QSize(100, 20);
}
virtual QSize minimumSizeHint() const
{
return this->sizeHint();
}
};
// hold the objects in a vertical layout
class Container : public QFrame
{
public:
Container(QWidget *i_pParent = NULL):
QFrame(i_pParent)
{
this->setFrameStyle(QFrame::Sunken | QFrame::Box);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setLayout(new QVBoxLayout(this));
for(int i = 0; i < 10; ++i)
{
this->layout()->addWidget(new Obj(this));
}
this->updateGeometry();
}
// never gets called
virtual QSize sizeHint() const
{
return QSize(1000, 1000);
}
// never gets called
virtual QSize minimumSizeHint() const
{
return this->sizeHint();
}
protected:
// never gets called
virtual void resizeEvent(QResizeEvent *i_pEvent)
{
}
};
class ScrollArea : public QScrollArea
{
public:
Container *m_pContainer;
ScrollArea(QWidget *i_pParent = NULL):
QScrollArea(i_pParent)
{
this->m_pContainer = new Container(this);
this->setViewport(this->m_pContainer);
this->setWidgetResizable(false);
// some messed up value "QRect(9,9 -18x-18)"
qDebug() << this->m_pContainer->layout()->contentsRect();
// QSize(1000,1000) as it ought to be
qDebug() << this->m_pContainer->size();
// false
qDebug() << this->widgetResizable();
}
};
int main(int argc, char **argv)
{
QApplication p_App(argc, argv);
ScrollArea p_ScrollArea;
p_ScrollArea.resize(250, 250);
// viewport downsized, no scollbars
p_ScrollArea.show();
// QSize(230,230) - where did the QSize(1000, 1000) go?
// resizeEvent wasn't called
// and it shouldn't resize at all!
qDebug() << p_ScrollArea.m_pContainer->size();
return p_App.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks