2

I have been able to resize the QTabWidget's QTabBar size, but the string inside is always limited to a fixed length.

QTabWidget *tabWidget = new QTabWidget;
tabWidget->setStyleSheet("QTabBar::tab { width: 100px; }");
tabWidget->addTab(imagesList, "abcdefghijklmnop");

The string shown is made of the central five/six characters only.

Thank you for any help,
Pietro

References: Qt Increase QTabWidget's QTabBar size

Community
  • 1
  • 1
Pietro
  • 12,086
  • 26
  • 100
  • 193

1 Answers1

1

When you specify the width of the tab using a style sheet as you do, you also make the width of the tab fixed. If the text is wider than the specified width you will only see whatever characters in the middle of the text that fit. Try increasing the tab width to 200px or 300px, or if it is the minimum width of the tab you want to set (and still have it become wider if needed) use the following style sheet:

tabWidget->setStyleSheet("QTabBar::tab { min-width: 100px; }");
Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
  • I tried to use "min-width", but nothing changed. Increasing the width manually (e.g. to 300px) increases the width of the tab, but the string inside is still truncated to the previous width. – Pietro Jan 03 '13 at 11:21