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. [SOLVED]QTabWidget icons without rotating
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QTabWidget icons without rotating

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.2k Views 1 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on 13 Aug 2013, 08:10 last edited by
    #1

    Howdy,

    I'm using QTabWidget as a sidebar for my application (similar to Qt Creator sidebar) so I set TabPosition to the East with empty labels but the icon of tabs appear rotated 90deg.

    How can I show icons of tab bar without rotating?

    P.S. In case there is no way to show icons without rotating Do you know another way for building sidebar easily.

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xcoder
      wrote on 13 Aug 2013, 08:41 last edited by
      #2

      Howdy,

      I would use QListWidget (even QListView with model) and QStackedWidgets to achieve the same effect Qt Creator has.
      Basically when you change the current row in list change the page in stack widget.

      Edit:

      Or learn from the best, and check the QtCreator source code.

      http://qt.gitorious.org/qt-creator/qt-creator/trees/master/src/plugins/coreplugin
      Here you can find FancyTabWidget class which is exactly what you are looking for.

      Only a biker knows why a dog sticks his head out of a car window.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbnoimi
        wrote on 13 Aug 2013, 16:08 last edited by
        #3

        [quote]I would use QListWidget (even QListView with model) and QStackedWidgets to achieve the same effect Qt Creator has.
        Basically when you change the current row in list change the page in stack widget.[/quote]
        Actually this was my first trial but I didn't prefer it because it needs hard code to customize where QTabWidget already has what I need (except icon issue :) )

        [quote] Here you can find FancyTabWidget class which is exactly what you are looking for.[/quote]

        Did you try it by yourself? I found it hard to use outside Qt Creator because it's part of it.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xcoder
          wrote on 15 Aug 2013, 10:52 last edited by
          #4

          Sorry for late reply. No unfortunately I have not, to be more helpful about fancywidget, I have to take a deeper look. It did look well organized so it should be failry easy to integrate in your own project. . In any case as I mentioned before. I would still go for QTableView and QStackedWidgets. Maybe even make my own widget out of those two, with my methods for adding pages and so on.

          Good luck.

          Only a biker knows why a dog sticks his head out of a car window.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbnoimi
            wrote on 17 Aug 2013, 16:26 last edited by
            #5

            I fixed it by controlling icon rotation manually:
            [code]
            QIcon icon = widget->windowIcon();
            QSize sz;
            for (int var = 0; var < icon.availableSizes().count(); ++var) {
            if (icon.availableSizes().at(var).width() > sz.width())
            sz = icon.availableSizes().at(var);
            }
            QPixmap pix = icon.pixmap(sz);
            QTransform trans;
            if (ui->tabWidget_sidebar->tabPosition() == QTabWidget::East)
            trans.rotate(-90);
            else
            trans.rotate(+90);
            pix = pix.transformed(trans);
            icon = QIcon(pix);
            ui->tabWidget_sidebar->addTab(widget, icon, "");
            [/code]

            1 Reply Last reply
            0

            1/5

            13 Aug 2013, 08:10

            • Login

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