0

I'm having trouble adding a QScrollArea to a layout within a QDialog widget. When I add the scroll area to the layout, it appears where I want it with the widget I've assigned to it and it scrolls just fine. However, I am also left with a blank scroll area stuck to the top left of my dialog, as if I hadn't added the scroll area to the layout at all!

Why is this happening?

Brian Spisak
  • 63
  • 1
  • 4
  • Did you set the correct parent? Parents are always widgets, not the layout. – Sebastian Lange Sep 24 '13 at 05:22
  • @SebastianLange: You don't need to set parent on widgets added to a layout. The layout does it automatically. – Kuba hasn't forgotten Monica Sep 24 '13 at 10:51
  • Your trouble is in the code you're not showing. As soon as you try to produce a minimum, stand-alone test case for your issue, you'll find what's wrong. If you can't just post it here. Make sure it's a single file `main.cpp`, and has `#include "main.moc"` at the end if you have any custom QObject classes. See, for example, [this answer](http://stackoverflow.com/a/18961945/1329652). – Kuba hasn't forgotten Monica Sep 24 '13 at 10:52
  • @Kuba Ober: I had the same problem when setting the **wrong** parent, thats why i intentionally said the parent needs to be a widget, especially the parent widget when given. – Sebastian Lange Sep 24 '13 at 10:53
  • @SebastianLange: Generally, you should not be setting any parents when layouts are involved. That's the safest way to go. No way of setting wrong parents then :) – Kuba hasn't forgotten Monica Sep 24 '13 at 10:55

0 Answers0