Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. mac: QTabWidget with large icons: how?
Forum Updated to NodeBB v4.3 + New Features

mac: QTabWidget with large icons: how?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 5 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davecotter
    wrote on 14 May 2019, 08:10 last edited by
    #1

    I want nice fat icons, like this:

    0_1557821365110_Screen Shot 2019-05-14 at 1.08.57 AM.png
    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 :/

    J 1 Reply Last reply 14 May 2019, 08:33
    0
    • O ollarch
      17 May 2019, 09:54

      @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.

      D Offline
      D Offline
      davecotter
      wrote on 17 May 2019, 20:02 last edited by
      #7

      @ollarch said in mac: QTabWidget with large icons: how?:

      it seems that they are using a QListWidget

      I believe that will work! usingsetFlow(QListView::LeftToRight)!

      thanks so much!

      1 Reply Last reply
      1
      • D davecotter
        14 May 2019, 08:10

        I want nice fat icons, like this:

        0_1557821365110_Screen Shot 2019-05-14 at 1.08.57 AM.png
        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 :/

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 14 May 2019, 08:33 last edited by
        #2

        @davecotter Are you adding tabs using https://doc.qt.io/qt-5/qtabwidget.html#addTab-1 ?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on 14 May 2019, 17:13 last edited by davecotter
          #3

          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; }");
          
          1 Reply Last reply
          0
          • D Offline
            D Offline
            davecotter
            wrote on 16 May 2019, 19:36 last edited by
            #4

            what i wanted was something like Qt Creator's icon bar with color icons:

            0_1558035366211_Screen Shot 2019-05-16 at 12.35.58 PM.png
            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?

            O 1 Reply Last reply 17 May 2019, 09:54
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 16 May 2019, 19:38 last edited by
              #5

              Hi,

              You should take a look at Qt Creator's source code. IIRC, they are using a custom style.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • D davecotter
                16 May 2019, 19:36

                what i wanted was something like Qt Creator's icon bar with color icons:

                0_1558035366211_Screen Shot 2019-05-16 at 12.35.58 PM.png
                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?

                O Offline
                O Offline
                ollarch
                wrote on 17 May 2019, 09:54 last edited by
                #6

                @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.

                D 1 Reply Last reply 17 May 2019, 20:02
                0
                • O ollarch
                  17 May 2019, 09:54

                  @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.

                  D Offline
                  D Offline
                  davecotter
                  wrote on 17 May 2019, 20:02 last edited by
                  #7

                  @ollarch said in mac: QTabWidget with large icons: how?:

                  it seems that they are using a QListWidget

                  I believe that will work! usingsetFlow(QListView::LeftToRight)!

                  thanks so much!

                  1 Reply Last reply
                  1
                  • D Offline
                    D Offline
                    davecotter
                    wrote on 20 May 2019, 22:35 last edited by
                    #8

                    by the way, here's my icon bar, FTW:

                    0_1558391718974_Screen Shot 2019-05-20 at 3.24.42 PM.png

                    A 1 Reply Last reply 27 Dec 2023, 01:47
                    2
                    • D davecotter
                      20 May 2019, 22:35

                      by the way, here's my icon bar, FTW:

                      0_1558391718974_Screen Shot 2019-05-20 at 3.24.42 PM.png

                      A Offline
                      A Offline
                      Ans1
                      wrote on 27 Dec 2023, 01:47 last edited by
                      #9

                      @davecotter
                      How did you do this?

                      D 1 Reply Last reply 28 Dec 2023, 22:34
                      1
                      • A Ans1
                        27 Dec 2023, 01:47

                        @davecotter
                        How did you do this?

                        D Offline
                        D Offline
                        davecotter
                        wrote on 28 Dec 2023, 22:34 last edited by
                        #10

                        @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);
                        	}
                        }
                        
                        
                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved