Skip to content
  • 0 Votes
    14 Posts
    2k Views
    J
    Ack, I hated COBOL. I don't use Qt Creator and write all the code from scratch. I suppose I have to learn it sometime. But I use Visual Studio to write in so it's got auto complete for that anyway. Plus, yes I know using Qt Creator means I wouldn't have made those glaring bad errors , but then I learn something, finding and tracking bugs down and asking questions gets you to understand the code a lot more, this is my personal opinion and it's the best way that works for me.
  • 0 Votes
    4 Posts
    2k Views
    Pl45m4P
    @vicky_mac A QStackedWidget works like a book. You have pages with your content. You can flip these pages to change your widget inplace (without opening another window or something else). So one possibility is to put one of each QTabWidget (each with a different tabBar position) on a page of a QStackedWidget. You could flip the pages by clicking a dummy tab on each tabBar or you use a button to go to the next page. I know, this is not exactly what the widget in your image looks like :) @vicky_mac said in How to Add multiple Qtoolbar in QtabWidget: Haven't used QT much If you want a widget, that looks exactly like the one shown above, you could still try to subclass and create your own, custom TabWidget, but I fear, that it might be a little too challenging. Here's all you need to know about QStackedWidget (https://doc.qt.io/qt-5/qstackedwidget.html#details)
  • 0 Votes
    3 Posts
    2k Views
    S
    @SGaist That's a fair question and to answer that it's because on the actual dock widget itself, in the production code, there are two widgets that get placed inside the dock widget itself. The topFrame contains the layout for the QTabWidget as you have pointed out. The code that is not present, botFrame contains another QGridLayout. These two then get placed inside the QGridLayout which is the layout of QGroupBox. Then to answer Why am I subclassing a layout to put widgets in it? I guess this is a personal decision and can be argued either way. For now, I will say that you are correct, that the Widget should manage the way the GridLayout adds widgets to them. However, I will argue that since QGridLayout is it's own class; the Widget does not "own" the widgets, rather, the layout owns the widgets since QWidget does not have a addWidgets function in it. Therefore, QGridLayout owns and is responsible for the Widgets that it owns. Hence the decision that the QWidget is the parent, which has a QGridLayout, which the QGridLayout as the Child, has the widgets that belong inside of it. This is a programming decision that I made with these arguments.
  • 0 Votes
    1 Posts
    493 Views
    No one has replied
  • 0 Votes
    10 Posts
    3k Views
    SGaistS
    Usually, it's the bigger widget added that sets the overall size of the QTabWidget.
  • 0 Votes
    11 Posts
    5k Views
    Y
    Thank You @SGaist and @AndyS. I am able to get QToolButton of QTabBar by applying Fusion style. I applied Fusion Style By: #include "mainwindow.h" #include <QTimer> #include <QtGlobal> #include <QFile> #include <QLocale> #include <QSplashScreen> #include <QGuiApplication> #include <qstylefactory.h> int main(int argc, char *argv[]) { QLocale::setDefault(QLocale::system()); QApplication a(argc, argv); a.setStyle(QStyleFactory::create("Fusion")); MainWindow w; w.showMaximized(); return a.exec(); }
  • Remove shadow from QTabWidget

    Solved General and Desktop shadow border qtabwidget
    3
    0 Votes
    3 Posts
    4k Views
    gde23G
    @mrjj Thx for the hint setStyleSheet("QTabWidget::pane {border-bottom: 0px;}"); did the trick
  • 0 Votes
    3 Posts
    2k Views
    VRoninV
    separate QTableWidget into a QTableView and a QStandardItemModel add a QSortFilterProxyModel as the model of QTableView and set the QStandardItemModel as the QSortFilterProxyModel's sourceModel call QSortFilterProxyModel::setFilterWildcard or QSortFilterProxyModel::setFilterRegExp to perform the searching See Basic Sort/Filter Model Example
  • 0 Votes
    3 Posts
    9k Views
    pauleddP
    Thank you! I see you specified height and width manually. That works so far. I will use that.
  • 0 Votes
    4 Posts
    11k Views
    H
    @raven-worx Great, it works. Actually I did try setting QTabWidget setAutoFillBackground(True) previously, but it didn't work. Now I tried set VGroupBox setAutoFillBackground(True), then the color changed to light grey which is the exact default color I need. Thanks so much, raven-worx.
  • QTabWidget: style each tab differently

    Unsolved General and Desktop qtabwidget qtabbar style c++ qt5
    5
    0 Votes
    5 Posts
    3k Views
    S
    @raven-worx ah right, couldn't be easier. :) Maybe I'll come up with another solution for my issue like subclassing and repainting the tabbar. For now that'll do the trick. Cheers
  • 0 Votes
    12 Posts
    6k Views
    mrjjM
    super :) its easy to overlook stuff in own code :)
  • QOpenGLWidget force initialisation

    Unsolved General and Desktop qopenglwidget qtabwidget
    2
    0 Votes
    2 Posts
    1k Views
    Fidchells_EyeF
    You'll need to change the context to the second GL widgets before using it. As each time you render or do anything with OpenGL setup/parameters that you have the right context selected first for each widget.
  • QTabWidget get the tab page's widgets

    Unsolved General and Desktop pyqt5 qtabwidget qwidget
    6
    0 Votes
    6 Posts
    6k Views
    SGaistS
    @Masonsu your QTextEdit is an implementation detail of your Chatlog widget. You should use e.g. a slot in Chatlog that will internally append the text to your QTextEdit. So if you change it for something else. You don't have to rewrite everything because of that.
  • Drag tabs between QTabWidgets

    Solved General and Desktop qtabwidget qtabbar tab drag drag and drop
    6
    0 Votes
    6 Posts
    10k Views
    A
    Had a similar Issue. Was able to find a solution. Below is a generic PyQt5 example that solves the problem using right click. import sys from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import * class Tabs(QTabWidget): def __init__(self, parent): super().__init__(parent) self.parent = parent self.setAcceptDrops(True) self.tabBar = self.tabBar() self.tabBar.setMouseTracking(True) self.indexTab = None self.setMovable(True) self.addTab(QWidget(self), 'Tab One') self.addTab(QWidget(self), 'Tab Two') def mouseMoveEvent(self, e): if e.buttons() != Qt.RightButton: return globalPos = self.mapToGlobal(e.pos()) tabBar = self.tabBar posInTab = tabBar.mapFromGlobal(globalPos) self.indexTab = tabBar.tabAt(e.pos()) tabRect = tabBar.tabRect(self.indexTab) pixmap = QPixmap(tabRect.size()) tabBar.render(pixmap,QPoint(),QRegion(tabRect)) mimeData = QMimeData() drag = QDrag(tabBar) drag.setMimeData(mimeData) drag.setPixmap(pixmap) cursor = QCursor(Qt.OpenHandCursor) drag.setHotSpot(e.pos() - posInTab) drag.setDragCursor(cursor.pixmap(),Qt.MoveAction) dropAction = drag.exec_(Qt.MoveAction) def dragEnterEvent(self, e): e.accept() if e.source().parentWidget() != self: return print(self.indexOf(self.widget(self.indexTab))) self.parent.TABINDEX = self.indexOf(self.widget(self.indexTab)) def dragLeaveEvent(self,e): e.accept() def dropEvent(self, e): print(self.parent.TABINDEX) if e.source().parentWidget() == self: return e.setDropAction(Qt.MoveAction) e.accept() counter = self.count() if counter == 0: self.addTab(e.source().parentWidget().widget(self.parent.TABINDEX),e.source().tabText(self.parent.TABINDEX)) else: self.insertTab(counter + 1 ,e.source().parentWidget().widget(self.parent.TABINDEX),e.source().tabText(self.parent.TABINDEX)) class Window(QWidget): def __init__(self): super().__init__() self.TABINDEX = 0 tabWidgetOne = Tabs(self) tabWidgetTwo = Tabs(self) layout = QHBoxLayout() self.moveWidget = None layout.addWidget(tabWidgetOne) layout.addWidget(tabWidgetTwo) self.setLayout(layout) if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
  • Layout each tab in QTabBar

    Unsolved General and Desktop qtabwidget qtabbar tabs layout
    6
    0 Votes
    6 Posts
    5k Views
    freddy311082F
    @Paul-Colby Yes paaul, it doesn't work for me neither any other advise ? regards
  • Several dock-related questions

    Unsolved Qt Creator and other tools qdockwidget qtabwidget
    4
    0 Votes
    4 Posts
    2k Views
    SGaistS
    QDockWidget and QMainWindow are tied. That doesn't prevent you to use another QMainWindow as a central widget for your QMainWindow even though that would be a bit strange. Note that if you only want to work with dock widgets nothing forbids you to not use any central widget.
  • QTabWidget - reorder Tabs with the designer

    Unsolved General and Desktop qtabwidget
    1
    0 Votes
    1 Posts
    625 Views
    No one has replied