mac: QTabWidget with large icons: how?
-
I want nice fat icons, like this:
except obviously i want the tab buttons to enlarge to contain the icons, and i want the icon text label to be underneath the icon.I can't seem to figure out how to do that :/
-
@ollarch said in mac: QTabWidget with large icons: how?:
it seems that they are using a QListWidget
I believe that will work! using
setFlow(QListView::LeftToRight)
!thanks so much!
-
@davecotter Are you adding tabs using https://doc.qt.io/qt-5/qtabwidget.html#addTab-1 ?
-
no i'm laying out the dialog in Qt Designer, i set the icon size there to 32 x 32, then i'm adding icons with:
tabBarP->setTabIcon();
is this just not supported in Qt ? if not, then why ENABLE the ability to set the icon size?
setting the style like this does NOT help:
tabBarP->setStyleSheet("QTabBar::tab { height: 36px; width: 36px; }");
-
what i wanted was something like Qt Creator's icon bar with color icons:
Lovely large icons, centered OVER the descriptive text. Just that that's vertical on the left, and i want mine horizontal across the top.How does one accomplish this?
-
Hi,
You should take a look at Qt Creator's source code. IIRC, they are using a custom style.
-
@davecotter I haven't inspected Qt Creator code but it seems that they are using a QListWidget. With the selected item you can use a QStackedWidget as your central widget.
-
@ollarch said in mac: QTabWidget with large icons: how?:
it seems that they are using a QListWidget
I believe that will work! using
setFlow(QListView::LeftToRight)
!thanks so much!
-
by the way, here's my icon bar, FTW:
-
@davecotter
How did you do this? -
@Ans1 i do not know if this helps, but here's my init code:
void QtDlgTabs::Panel_Setup() { CDialog* dlgP(GetDialog<CDialog>()); QListWidget *listP(dlgP->QtGetItem<QListWidget>(Dlg_Tabs_ICON_BAR)); Rect iconR = { 0, 0, 64, 64 }; CPixels pix(iconR); ScCGContext context(pix); Qt::ItemFlags flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); float scaleF(devicePixelRatio()); // doesn't work pix.setDevicePixelRatio(scaleF); static int s_awidthI = 61; static int s_heightI = 50; int s_widthI = 150; bool is_prefsB(dlgP->GetPanelSet() == PrefPanelSet_PREFS); if (is_prefsB) { s_widthI = 70; } int widthI = s_widthI; if (is_prefsB) { if (dlgP->GetAllControlsVisible()) { widthI = s_awidthI; } } listP->setGridSize(QSize(widthI, s_heightI)); PrefPanelSet panelSet(dlgP->GetPanelSet()); SInt16Vec& panelVec(GetPanelVec(panelSet)); for (SInt16 indexS: panelVec) { PanelRec& curPanel(*GetIndPanelRec(panelSet, indexS)); QListWidgetItem *listItemP(new QListWidgetItem()); SuperString nameStr(GetLocalizedPrefPaneName(panelSet, curPanel.prefPanelS)); SDB_SourceType iconType(static_cast<SDB_SourceType>(curPanel.sourceType)); QFont itemFont(listItemP->font()); pix.clear(); gApp->Draw_icns(&context, iconType, iconR, kTransformNone); itemFont.setPointSize(itemFont.pointSize() - 1); listItemP->setFont(itemFont); listItemP->setText(nameStr); listItemP->setIcon(pix); listItemP->setFlags(flags); listP->addItem(listItemP); } }