How to keep widget's size to one which is just sufficiennt to display contents?
Hi
Here is the constructor for main widget:
Code:
GMessenger
::GMessenger() : QWidget(0, Qt
::WindowStaysOnTopHint | Qt
::FramelessWindowHint){ setLayout(m_pLayout);
}
Here is the constructor for child widget:
Code:
GMessenger
::ProgressJobNotifier::ProgressJobNotifier(const QString &title
) : QFrame(0){
...
setLayout(m_pVLayout);
}
QFrame derived child widget increases/decreases its size when a child widget is added to it, while QWidget derived top level widget increases its size when a child widget is added but not decreases its size when a child widget is removed (Which is what i want). So help please!
Re: How to keep widget's size to one which is just sufficiennt to display contents?
Quote:
Originally Posted by
yogeshm02
QWidget derived top level widget increases its size when a child widget is added but not decreases its size when a child widget is removed (Which is what i want).
Are you sure? Judging from the title of your post, you want the opposite.
QWidget::adjustSize()
Re: How to keep widget's size to one which is just sufficiennt to display contents?
Re: How to keep widget's size to one which is just sufficiennt to display contents?
QLayout::setSizeConstraint(QLayout::SetFixedSize) is working :)
But, it seems like I'll have to invest more time understanding behaviour of QLayout::setSizeConstraint(QLayout::SetFixedSize) and setSizePolicy(QSizePolicy::Policy, QSizePolicy::Policy)
Bye
Re: How to keep widget's size to one which is just sufficiennt to display contents?
The difference is simple - sizepolicy constrains the size of a widget when that widget is in a layout (so it doesn't work for top level widgets) and setSizeConstraint controls the parent of the layout (or rather the layout itself).