[SOLVED]QTabWidget icons without rotating



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



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



  • [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.



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



  • 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]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.