qtabwidget

Show/Hide sub-tab on QTabWidget

…衆ロ難τιáo~ 提交于 2019-12-22 05: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! 回答1: 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

PyQt multiple tablewidgets and tabwidgets

安稳与你 提交于 2019-12-20 03:06:04
问题 My objective is to display 10 or more QTabWidget in a single QMainWindow , each tab holding a unique QLabel and QTableWidget . Something like this: Even though i managed to get the intended result by using the following code, i am wondering if there is more efficient way or shorter way to achieve the same result. Tab = QtGui.QTabWidget() Tab1 = QtGui.QWidget() Tab2 = QtGui.QWidget() Tab3 = QtGui.QWidget() Tab4 = QtGui.QWidget() Tab5 = QtGui.QWidget() Tab6 = QtGui.QWidget() Tab7 = QtGui

PyQt4: How to color each tab in QTabWidget separately?

核能气质少年 提交于 2019-12-13 03:05:02
问题 I'm working on a project with a GUI, for which I am using Python with PyQt4 module. Here is my demo code: import sys from PyQt4 import QtGui, QtCore class Window(QtGui.QMainWindow): def __init__(self): super(Window, self).__init__() self.setWindowTitle('PyQt4 demo') self.setGeometry(50, 50, 1000, 1000) self.createTabs() self.styleTabs() self.show() def createTabs(self): '''Creates a QTabWidget with 5 tabs, named 1, 2, 3, 4, 5 ''' self.tabs = QtGui.QTabWidget(self) self.tabs.resize(1000, 1000)

QTabWidget increase tab scroller arrow button width

送分小仙女□ 提交于 2019-12-12 09:22:15
问题 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;

QTabWidget with multiple line?

戏子无情 提交于 2019-12-12 04:47:51
问题 Is it possible to make QTabWidget behave like windows system , use multiple line when there's just too much tabs ? I checked qt's doc , seems no such thing was available. 回答1: You would need to subclass QTabWidget or Widget and implement this functionality yourself. I would recommend that you consider a different approach if you plan more tabs than will conveniently all fit in a single line (without arrows or multiple rows). Tabs on multiple rows, although common enough, are widely considered

QTabWidget tabPosition when using stylesheets

家住魔仙堡 提交于 2019-12-11 06:26:18
问题 I'm currently using stylesheets to theme an application. Here is the stylesheet I use for QTabWidget: /*QTabBar et QTabWidget*/ QTabBar::tab { background: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(73, 73, 74, 255), stop:1 rgba(40, 40, 40, 255)); border: 1px solid rgb(190, 190, 190); max-height: 0.6em; min-width: 0.6em; padding: 5px; margin-left: -1px; margin-right: -1px; } QTabBar::tab:selected, QTabBar::tab:hover { background: qlineargradient(spread:pad, x1:0.5, y1

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

半世苍凉 提交于 2019-12-10 10:26:37
问题 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++) {

Putting a close button on QTabWidget

≯℡__Kan透↙ 提交于 2019-12-10 02:15:45
问题 I'm using a QTabWidget to render multiple documents in a window, and I want to draw a close button on each tab. I'm using Vista and Qt4 , so the tab widget is a native windows control; this may affect the feasibility. Does anyone know if it is possible to do this using the QTabWidget control, or do I have to create a custom widget? If creating a new widget is the only option, any pointers would be much appreciated; I'm relatively new to Qt. 回答1: Currently there is no way to do this with the

Setting color of Tab part of QTabWidget

梦想的初衷 提交于 2019-12-08 11:44:52
问题 When I change the background color of the QTabWidget, the tab part of the widget doesn't change colors. Looking online there doesn't seem to be a simple way to set this color. Suggestions? 回答1: You can do that using Qt's style sheets. From the docs: /* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ QTabBar::tab { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); border:

QTabWidget with CheckBox in title

孤街浪徒 提交于 2019-12-07 12:01:00
问题 I was wondering how to create (using PyQt4) a derived QTabWidget with a check box next to each tab title? Like this: 回答1: 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