qtabwidget

In PyQt4, is it possible to detach tabs from a QTabWidget?

谁说胖子不能爱 提交于 2019-12-07 07:01:56
问题 Many professional applications (such as web browsers) give the user the ability to detach tabs from a tab bar. Surprisingly, Qt4 does not provide this functionality. Some might say that this functionality is provided by using tabified QDockWidgets. However, it could also be argued that QDockWidgets implementation makes it look unprofessional and un-intuitive to users. 回答1: I found a partially working C++ example in this post on the Qt Centre forum. It was incomplete and buggy. However, I was

How to change text alignment in QTabWidget in C++?

核能气质少年 提交于 2019-12-05 21:21:24
This is the same question as in: How to change text alignment in QTabWidget? I tried to port that python code into C++ but it doesn't seem to work. Here is header file: #include <QTabBar> class HorizontalTabWidget : public QTabBar { Q_OBJECT public: explicit HorizontalTabWidget(QWidget *parent = 0); protected: void paintEvent(QPaintEvent *); QSize sizeHint() const; }; Here is source file: void HorizontalTabWidget::paintEvent(QPaintEvent *) { for(int index = 0; index < count(); index++) { QPainter * painter = new QPainter(this); painter->begin(this); painter->setPen(Qt::blue); painter->setFont

QTabWidget with CheckBox in title

孤街醉人 提交于 2019-12-05 16:49:50
I was wondering how to create (using PyQt4) a derived QTabWidget with a check box next to each tab title? Like this: Jib Actually I chose to only subclass QTabWidget. The checkBox is added at the creation of a new tab and saved to a list in order to get its index back. setCheckState/isChecked methods are intended to control the state of each checkBox specified by its tab index. Finally, the "stateChanged(int)" signal is captured and remitted with an extra parameter specifying the index of the checkBox concerned. class CheckableTabWidget(QtGui.QTabWidget): checkBoxList = [] def addTab(self,

PyQt5 How To Set TabWidget West But Keep The Text Horizontal

岁酱吖の 提交于 2019-12-05 16:03:56
How To Make Text Direction From Left To Right Instade Of Top To Bottom In this answer I will make a python translation of my another answer written in C++. from PyQt5 import QtCore, QtGui, QtWidgets class TabBar(QtWidgets.QTabBar): def tabSizeHint(self, index): s = QtWidgets.QTabBar.tabSizeHint(self, index) s.transpose() return s def paintEvent(self, event): painter = QtWidgets.QStylePainter(self) opt = QtWidgets.QStyleOptionTab() for i in range(self.count()): self.initStyleOption(opt, i) painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, opt) painter.save() s = opt.rect.size() s

In PyQt4, is it possible to detach tabs from a QTabWidget?

◇◆丶佛笑我妖孽 提交于 2019-12-05 15:16:28
Many professional applications (such as web browsers) give the user the ability to detach tabs from a tab bar. Surprisingly, Qt4 does not provide this functionality. Some might say that this functionality is provided by using tabified QDockWidgets. However, it could also be argued that QDockWidgets implementation makes it look unprofessional and un-intuitive to users. I found a partially working C++ example in this post on the Qt Centre forum. It was incomplete and buggy. However, I was able to use it as reference and a starting point to create my own DetachableTabWidget using PyQt. Since I

PyQt mouse events for QTabWidget

家住魔仙堡 提交于 2019-12-05 09:16:52
I want to detect middle mouse clicks on a QTabWidget. I was expecting there to be a mouse event related signal on QWidget, but all I am seeing are methods. Do I need to subclass the QTabWidget and then override said methods in order to do what I want, or am I missing something? You can either install an event filter on the QTabBar (returned by QTabWidget.tabBar() ) to receive and handle press and release events, or subclass QTabBar to redefine mousePressEvent and mouseReleaseEvent and replace the QTabBar of the QTabWidget with QTabWidget.setTabBar() . Example using the event filter: class

Show/Hide sub-tab on QTabWidget

删除回忆录丶 提交于 2019-12-05 06:48:17
Assuming I have a QTabWidget that contains 5 sub-tabs. Now I want to show/hide a sub-tab in one of 5 sub-tabs by following code ui->twListTabs->widget(0)->hide(); // Hide first sub-tab But this didn’t work for me. Do you have any solutions? Thanks! You only have the option to use: void QTabWidget::removeTab(int index) You need to store the pointer to the QWidget in the tab so that you can later insert it. You could e.g. do something like: class TabWidget : public QTabWidget { Q_OBJECT enum tabwidgets {tabwidget1,tabwidget2,...,number_of_tabwidgets}; QWidget* widgets_[number_of_tabwidgets];

QTabWidget increase tab scroller arrow button width

和自甴很熟 提交于 2019-12-04 21:51:43
I have a QTabWidget with too many tabs and they overflow with scroller arrows. I want to increase the width of the scroller arrows by more than twice of the default width so they are easier to use on a touchscreen. There is a QTabWidget StyleSheet example but I cannot seem to get it to work nicely. The stylesheet below produces this screenshot QTabBar::scroller { /* the width of the scroll buttons */ width: 40px; } QTabBar QToolButton { /* the scroll buttons are tool buttons */ width: 15px; border-width: 2px; } where I would like something like this screenshot I edited. Method #1: This appears

How to implement vertical tabs in QT?

微笑、不失礼 提交于 2019-12-03 13:51:16
问题 I am trying to implement vertical tabs with horizontal text with QT but I cannot find any similar option in QTabWidget . Somebody in SO asked for something similar here, however, the answers contain broken links and I doubt that they present a real solution. Anybody has been able to do that? 回答1: You have to implement a custom QTabBar overwriting the tabSizeHint() and paintEvent() methods as shown below: #include <QApplication> #include <QStyleOptionTab> #include <QStylePainter> #include

QTabWidget tabs on the vertical, but text in horizontal

独自空忆成欢 提交于 2019-12-03 11:48:55
问题 I'm trying to make an app in C++ Qt with a sidebar like this one: But when making QTabWidget's orientation to West, it makes the text vertical. How to have the text on the left, but horizontally-aligned? Ps: I don't need icons. Thanks in advance. 回答1: You can use QListWidget to show the "tabs" (with some mods to make it look like you want) and QStackedWidget to handle switching between pages like normal tab widget does. 回答2: A bit of "advertising" for a WTFPL implementation here on assembla