PDA

View Full Version : Simple QScrollArea problem



jmsbc
2nd December 2008, 01:20
Hi,

I'm not seeing my widget window when I'm trying put it into a QScrollArea with QFrame.

I designed a gui (MyWidget) using designer.

I placed all the buttons of my gui inside of a QFrame (like Wysota suggested in another thread), and then promoted the QFrame to QScrollArea and called it scrollFrame.

So in my code, my constructor looks like this:




MyWidget::MyWidget (QWidget *parent, Qt::WFlags flags)
: QWidget(parent, flags)
{
ui.setupUi(this);
ui.scrollFrame->setWidget(this);
}


My main looks like this:


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();

return a.exec();
}


However nothing shows up when I try to run this. Can somebody please help me figure out how to bring up the scrollbars?

Thank you.

jpn
2nd December 2008, 18:18
Hi,




ui.setupUi(this);
ui.scrollFrame->setWidget(this);


I'm sorry, but this code doesn't make any sense. You have a window. First you load a designed form on the window. At this stage the window contains a scroll area. Then you try to set the window inside that scroll area. :)

PS. Please don't double post!

jmsbc
2nd December 2008, 18:33
Crap you're right sorry about that.

Let's say I have a calendar widget inside of the QScrollArea's QFrame and then I do



ScrollTest::ScrollTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
ui.scrollFrame->setWidget(ui.calendarWidget);
}


This will show me the window with calenderWidget, but when I resize the window smaller than the calendar, scrollbars do not show up.

I'm probably doing something really wrong, please help!

jpn
2nd December 2008, 18:35
This will show me the window with calenderWidget, but when I resize the window smaller than the calendar, scrollbars do not show up.
You're probably missing the top level layout. See Setting A Top Level Layout (http://doc.trolltech.com/4.4/designer-editing-mode.html#setting-a-top-level-layout) for more details.

jmsbc
2nd December 2008, 18:45
omg i'm retarded,

Thanks a lot jpn!