Advertisement
KukuRuzo

hack tabs

Apr 4th, 2024
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. diff --git a/src/widgets/psitabbar.cpp b/src/widgets/psitabbar.cpp
  2. index c674d142..662b94f5 100644
  3. --- a/src/widgets/psitabbar.cpp
  4. +++ b/src/widgets/psitabbar.cpp
  5. @@ -26,6 +26,10 @@
  6.  #include <QMimeData>
  7.  #include <QMouseEvent>
  8.  #include <QPainter>
  9. +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  10. +#include <QMetaProperty>
  11. +#include <QStyleOptionTab>
  12. +#endif
  13.  
  14.  /**
  15.   * Constructor
  16. @@ -37,6 +41,19 @@ PsiTabBar::PsiTabBar(PsiTabWidget *parent) : TabBar(parent)
  17.      setMovable(true);
  18.      setTabsClosable(true);
  19.      setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
  20. +//Hack to place Qt6 tabs not at center with minimal tab width
  21. +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  22. +    setExpanding(false);
  23. +    auto propName = "position";
  24. +    auto *metaObject = PsiTabBar::metaObject();
  25. +    int count = metaObject->propertyCount();
  26. +    for (int i = 0; i < count; ++i) {
  27. +        if(std::strcmp(metaObject->property(i).name(), propName)) {
  28. +            setProperty(propName, QStyleOptionTab::Beginning);
  29. +            break;
  30. +        }
  31. +    }
  32. +#endif
  33.  }
  34.  
  35.  /**
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement