From 2916d5f4ee32d779120a6adf4bfc4591c57f7f4a Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 11 Mar 2014 20:57:41 +0000 Subject: [PATCH] Fixup button bar with lots of texts --- src/ChartBar.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ChartBar.cpp b/src/ChartBar.cpp index fd6ce6561..7106a87f8 100644 --- a/src/ChartBar.cpp +++ b/src/ChartBar.cpp @@ -133,7 +133,7 @@ ChartBar::addWidget(QString title) // make the right size QFontMetrics fontMetric(buttonFont); int width = fontMetric.width(title); - newbutton->setWidth(width+20); + newbutton->setFixedWidth(width+20); // add to layout layout->addWidget(newbutton); @@ -164,6 +164,17 @@ ChartBar::setText(int index, QString text) void ChartBar::tidy() { + // resize to button widths + 2px spacing + int width = 2; +#ifdef Q_OS_MAC + foreach (QtMacButton *button, buttons) { +#else + foreach (GcScopeButton *button, buttons) { +#endif + width += button->geometry().width() + 2; + } + buttonBar->setFixedWidth(width); + if (buttonBar->width() > scrollArea->width()) { left->show(); right->show(); } else {