#!/usr/bin/env python

import sys
from python_qt_binding.QtCore import QSettings, Qt
from python_qt_binding.QtGui import QAction, QApplication, QDockWidget, QToolBar, QMainWindow

app = QApplication(sys.argv)

settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 'test', 'test')

mw = QMainWindow()
mw.resize(800, 600)
mw.show()

tb = QToolBar()
tb.setObjectName('toolbar')
mw.addToolBar(tb)

count_dock_widgets = 0

def add_dock_widget(orientation):
    global count_dock_widgets
    count_dock_widgets += 1
    dw = QDockWidget('dockwidget%d' % count_dock_widgets, mw)
    dw.setObjectName('dockwidget%d' % count_dock_widgets)
    mw.addDockWidget(Qt.BottomDockWidgetArea, dw, orientation)

def add_horizontal(self):
    add_dock_widget(Qt.Horizontal)

def add_vertical(self):
Пример #2
0
    combo = QComboBox()
    combo.setEditable(True)
    combo_completer = TopicCompleter(combo)
    # combo_completer.setCompletionMode(QCompleter.InlineCompletion)
    combo.lineEdit().setCompleter(combo_completer)

    model_tree = QTreeView()
    model_tree.setModel(combo_completer.model())
    model_tree.expandAll()
    for column in range(combo_completer.model().columnCount()):
        model_tree.resizeColumnToContents(column)

    completion_tree = QTreeView()
    completion_tree.setModel(combo_completer.completionModel())
    completion_tree.expandAll()
    for column in range(combo_completer.completionModel().columnCount()):
        completion_tree.resizeColumnToContents(column)

    layout.addWidget(model_tree)
    layout.addWidget(completion_tree)
    layout.addWidget(edit)
    layout.addWidget(combo)
    layout.setStretchFactor(model_tree, 1)
    widget.setLayout(layout)
    mw.setCentralWidget(widget)

    mw.move(300, 0)
    mw.resize(800, 900)
    mw.show()
    app.exec_()
    def save_settings(self, settings):
        settings.set_value('dockable', self.dockable_button.isChecked())

    def restore_settings(self, settings):
        self.dockable_button.setChecked(settings.value('dockable', True) in [True, 'true'])
        self._toggle_dockable(self.dockable_button.isChecked())


if __name__ == '__main__':
    import sys
    from python_qt_binding.QtGui import QApplication, QMainWindow

    app = QApplication(sys.argv)

    win = QMainWindow()

    dock1 = QDockWidget('dockwidget1', win)
    win.addDockWidget(Qt.LeftDockWidgetArea, dock1)
    title_bar = DockWidgetTitleBar(dock1)
    dock1.setTitleBarWidget(title_bar)

    dock2 = QDockWidget('dockwidget2')
    win.addDockWidget(Qt.RightDockWidgetArea, dock2)
    title_bar = DockWidgetTitleBar(dock2)
    dock2.setTitleBarWidget(title_bar)

    win.resize(640, 480)
    win.show()

    app.exec_()