summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-05-15 16:27:34 +0200
committerNorwegian Rock Cat <qt-info@nokia.com>2009-05-15 16:27:34 +0200
commit06dba5e913def3b5f0fc77b9c11ba3a59c786617 (patch)
tree7a94aac334da324f7a3921614a70a399ac1f2dcf
parent25213744d532257fdf20dddd91bfadb272c066a5 (diff)
update sizepolicy and sizehint
-rw-r--r--example/simple/main.cpp3
-rw-r--r--src/qtsegmentcontrol.cpp6
2 files changed, 7 insertions, 2 deletions
diff --git a/example/simple/main.cpp b/example/simple/main.cpp
index 0da6f18..d4ae8c9 100644
--- a/example/simple/main.cpp
+++ b/example/simple/main.cpp
@@ -17,8 +17,9 @@ int main(int argc, char **argv)
segmentControl->setSegmentText(3, "Lisa");
segmentControl->setSegmentText(4, "Maggie");
- QVBoxLayout *vboxlayout = new QVBoxLayout(&widget);
+ QVBoxLayout *vboxlayout = new QVBoxLayout();
vboxlayout->addWidget(segmentControl);
+ widget.setLayout(vboxlayout);
widget.show();
return app.exec();
diff --git a/src/qtsegmentcontrol.cpp b/src/qtsegmentcontrol.cpp
index fd28fa8..0ec9257 100644
--- a/src/qtsegmentcontrol.cpp
+++ b/src/qtsegmentcontrol.cpp
@@ -113,6 +113,7 @@ static QSize segmentSizeFromContents(const QStyleOption *option, const QSize &co
if (const QtStyleOptionSegmentControlSegment *segment
= static_cast<const QtStyleOptionSegmentControlSegment *>(option)) {
ret.rwidth() += 20;
+ ret.rheight() += 10;
if (!segment->icon.isNull())
ret.rwidth() += 5;
}
@@ -163,6 +164,9 @@ void QtSegmentControlPrivate::postUpdate(int /*index*/, bool geoToo)
QtSegmentControl::QtSegmentControl(QWidget *parent)
: QWidget(parent), d(new QtSegmentControlPrivate(this))
{
+ setFocusPolicy(Qt::TabFocus);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ setAttribute(Qt::WA_WState_OwnSizePolicy, false);
}
QtSegmentControl::~QtSegmentControl()
@@ -344,7 +348,7 @@ QSize QtSegmentControl::sizeHint() const
QRect rect;
const int segmentCount = d->segments.count();
for (int i = 0; i < segmentCount; ++i) {
- rect.unite(segmentRect(i));
+ rect = rect.united(segmentRect(i));
}
return rect.size();
}