当前位置: 首页>>代码示例>>Python>>正文


Python Qt.QTreeView类代码示例

本文整理汇总了Python中PyQt5.Qt.QTreeView的典型用法代码示例。如果您正苦于以下问题:Python QTreeView类的具体用法?Python QTreeView怎么用?Python QTreeView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTreeView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, *args):
        QTreeView.__init__(self, *args)
        self.delegate = Delegate(self)
        self.setItemDelegate(self.delegate)
        self.setMinimumWidth(80)
        self.header().close()
        self.setMouseTracking(True)
        self.setStyleSheet('''
                QTreeView {
                    background-color: palette(window);
                    color: palette(window-text);
                    border: none;
                }

                QTreeView::item {
                    border: 1px solid transparent;
                    padding-top:0.5ex;
                    padding-bottom:0.5ex;
                }

                QTreeView::item:hover {
                    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
                    border: 1px solid #bfcde4;
                    border-radius: 6px;
                }
        ''')
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.context_menu)
开发者ID:j-howell,项目名称:calibre,代码行数:28,代码来源:toc.py

示例2: dragMoveEvent

 def dragMoveEvent(self, event):
     QTreeView.dragMoveEvent(self, event)
     self.setDropIndicatorShown(False)
     index = self.indexAt(event.pos())
     if not index.isValid():
         return
     src_is_tb = event.mimeData().hasFormat('application/calibre+from_tag_browser')
     item = index.data(Qt.UserRole)
     if item.type == TagTreeItem.ROOT:
         return
     flags = self._model.flags(index)
     if item.type == TagTreeItem.TAG and flags & Qt.ItemIsDropEnabled:
         self.setDropIndicatorShown(not src_is_tb)
         return
     if item.type == TagTreeItem.CATEGORY and not item.is_gst:
         fm_dest = self.db.metadata_for_field(item.category_key)
         if fm_dest['kind'] == 'user':
             if src_is_tb:
                 if event.dropAction() == Qt.MoveAction:
                     data = bytes(event.mimeData().data('application/calibre+from_tag_browser'))
                     src = json_loads(data)
                     for s in src:
                         if s[0] == TagTreeItem.TAG and \
                                 (not s[1].startswith('@') or s[2]):
                             return
                 self.setDropIndicatorShown(True)
                 return
             md = event.mimeData()
             if hasattr(md, 'column_name'):
                 fm_src = self.db.metadata_for_field(md.column_name)
                 if md.column_name in ['authors', 'publisher', 'series'] or \
                         (fm_src['is_custom'] and (
                          (fm_src['datatype'] in ['series', 'text', 'enumeration'] and not fm_src['is_multiple']) or (
                              fm_src['datatype'] == 'composite' and fm_src['display'].get('make_category', False)))):
                     self.setDropIndicatorShown(True)
开发者ID:j-howell,项目名称:calibre,代码行数:35,代码来源:view.py

示例3: mouseMoveEvent

 def mouseMoveEvent(self, event):
     dex = self.indexAt(event.pos())
     if dex.isValid():
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.unsetCursor()
     if not event.buttons() & Qt.LeftButton:
         return
     if self.in_drag_drop or not dex.isValid():
         QTreeView.mouseMoveEvent(self, event)
         return
     # Must deal with odd case where the node being dragged is 'virtual',
     # created to form a hierarchy. We can't really drag this node, but in
     # addition we can't allow drag recognition to notice going over some
     # other node and grabbing that one. So we set in_drag_drop to prevent
     # this from happening, turning it off when the user lifts the button.
     self.in_drag_drop = True
     if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
         QTreeView.mouseMoveEvent(self, event)
         return
     md = self._model.mimeData([dex])
     pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
     drag = QDrag(self)
     drag.setPixmap(pixmap)
     drag.setMimeData(md)
     if self._model.is_in_user_category(dex):
         drag.exec_(Qt.CopyAction|Qt.MoveAction, Qt.CopyAction)
     else:
         drag.exec_(Qt.CopyAction)
开发者ID:Aliminator666,项目名称:calibre,代码行数:29,代码来源:view.py

示例4: __init__

    def __init__(self, parent=None):
        QTreeView.__init__(self, parent=None)
        self.alter_tb = None
        self.disable_recounting = False
        self.setUniformRowHeights(True)
        self.setCursor(Qt.PointingHandCursor)
        self.setIconSize(QSize(20, 20))
        self.setTabKeyNavigation(True)
        self.setAnimated(True)
        self.setHeaderHidden(True)
        self.setItemDelegate(TagDelegate(self))
        self.made_connections = False
        self.setAcceptDrops(True)
        self.setDragEnabled(True)
        self.setDragDropMode(self.DragDrop)
        self.setDropIndicatorShown(True)
        self.in_drag_drop = False
        self.setAutoExpandDelay(500)
        self.pane_is_visible = False
        self.search_icon = QIcon(I("search.png"))
        self.user_category_icon = QIcon(I("tb_folder.png"))
        self.delete_icon = QIcon(I("list_remove.png"))
        self.rename_icon = QIcon(I("edit-undo.png"))

        self._model = TagsModel(self)
        self._model.search_item_renamed.connect(self.search_item_renamed)
        self._model.refresh_required.connect(self.refresh_required, type=Qt.QueuedConnection)
        self._model.tag_item_renamed.connect(self.tag_item_renamed)
        self._model.restriction_error.connect(self.restriction_error)
        self._model.user_categories_edited.connect(self.user_categories_edited, type=Qt.QueuedConnection)
        self._model.drag_drop_finished.connect(self.drag_drop_finished)
        stylish_tb = """
                QTreeView {
                    background-color: palette(window);
                    color: palette(window-text);
                    border: none;
                }
        """
        self.setStyleSheet(
            """
                QTreeView::item {
                    border: 1px solid transparent;
                    padding-top:0.8ex;
                    padding-bottom:0.8ex;
                }

                QTreeView::item:hover {
                    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
                    border: 1px solid #bfcde4;
                    border-radius: 6px;
                }
        """
            + ("" if gprefs["tag_browser_old_look"] else stylish_tb)
        )
        if gprefs["tag_browser_old_look"]:
            self.setAlternatingRowColors(True)
        # Allowing keyboard focus looks bad in the Qt Fusion style and is useless
        # anyway since the enter/spacebar keys do nothing
        self.setFocusPolicy(Qt.NoFocus)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:59,代码来源:view.py

示例5: __init__

    def __init__(self, *args):
        QTreeView.__init__(self,*args)

        self._model = Matches()
        self.setModel(self._model)

        self.rt_delegate = RichTextDelegate(self)

        for i in self._model.HTML_COLS:
            self.setItemDelegateForColumn(i, self.rt_delegate)
开发者ID:AEliu,项目名称:calibre,代码行数:10,代码来源:results_view.py

示例6: __init__

 def __init__(self, parent=None):
     QTreeView.__init__(self, parent)
     self.setHeaderHidden(True)
     self.setAnimated(True)
     self.activated.connect(self.item_activated)
     self.clicked.connect(self.item_activated)
     pi = plugins['progress_indicator'][0]
     if hasattr(pi, 'set_no_activate_on_click'):
         pi.set_no_activate_on_click(self)
     self.initialized = False
     self.setExpandsOnDoubleClick(False)
开发者ID:artbycrunk,项目名称:calibre,代码行数:11,代码来源:char_select.py

示例7: keyPressEvent

 def keyPressEvent(self, event):
     try:
         if self.handle_shortcuts(event):
             return
     except AttributeError:
         pass
     return QTreeView.keyPressEvent(self, event)
开发者ID:j-howell,项目名称:calibre,代码行数:7,代码来源:toc.py

示例8: __init__

 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self._layout = l = QGridLayout()
     self.setLayout(self._layout)
     self.header = QLabel(_('Double click on any entry to change the'
         ' keyboard shortcuts associated with it'))
     l.addWidget(self.header, 0, 0, 1, 3)
     self.view = QTreeView(self)
     self.view.setAlternatingRowColors(True)
     self.view.setHeaderHidden(True)
     self.view.setAnimated(True)
     l.addWidget(self.view, 1, 0, 1, 3)
     self.delegate = Delegate()
     self.view.setItemDelegate(self.delegate)
     self.delegate.sizeHintChanged.connect(self.editor_opened,
             type=Qt.QueuedConnection)
     self.delegate.changed_signal.connect(self.changed_signal)
     self.search = SearchBox2(self)
     self.search.initialize('shortcuts_search_history',
             help_text=_('Search for a shortcut by name'))
     self.search.search.connect(self.find)
     l.addWidget(self.search, 2, 0, 1, 1)
     self.nb = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self)
     self.pb = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self)
     self.nb.clicked.connect(self.find_next)
     self.pb.clicked.connect(self.find_previous)
     l.addWidget(self.nb, 2, 1, 1, 1)
     l.addWidget(self.pb, 2, 2, 1, 1)
     l.setColumnStretch(0, 100)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:29,代码来源:keyboard.py

示例9: __init__

    def __init__(self, *args):
        QTreeView.__init__(self,*args)

        self._model = Matches([p for p in store_plugins()])
        self.setModel(self._model)

        self.setIconSize(QSize(24, 24))

        self.rt_delegate = RichTextDelegate(self)

        for i in self._model.HTML_COLS:
            self.setItemDelegateForColumn(i, self.rt_delegate)

        for i in range(self._model.columnCount()):
            self.resizeColumnToContents(i)

        self.model().sort(1, Qt.AscendingOrder)
        self.header().setSortIndicator(self.model().sort_col, self.model().sort_order)
开发者ID:j-howell,项目名称:calibre,代码行数:18,代码来源:results_view.py

示例10: setLeftPage

    def setLeftPage(self):

        self.treeView = QTreeView(self)
        self.treeView.setObjectName("treeView")
        self.left_page_Layout.addWidget(self.treeView)
        self.treeView.activated.connect(self.changeCurrentSet)
        self.tree_model = TreeModel(self.model)
        self.treeView.setModel(self.tree_model)
        self.treeView.setWindowTitle("Simple Tree Model")
        self.treeView.header().hide()
        self.treeView.setAlternatingRowColors(True)
开发者ID:cyril711,项目名称:git-MythicWar,代码行数:11,代码来源:book_warrior_homepage.py

示例11: __init__

    def __init__(self, parent=None):
        QTreeView.__init__(self, parent=None)
        self.setMouseTracking(True)
        self.alter_tb = None
        self.disable_recounting = False
        self.setUniformRowHeights(True)
        self.setIconSize(QSize(20, 20))
        self.setTabKeyNavigation(True)
        self.setAnimated(True)
        self.setHeaderHidden(True)
        self.setItemDelegate(TagDelegate(self))
        self.made_connections = False
        self.setAcceptDrops(True)
        self.setDragEnabled(True)
        self.setDragDropMode(self.DragDrop)
        self.setDropIndicatorShown(True)
        self.in_drag_drop = False
        self.setAutoExpandDelay(500)
        self.pane_is_visible = False
        self.search_icon = QIcon(I('search.png'))
        self.search_copy_icon = QIcon(I("search_copy_saved.png"))
        self.user_category_icon = QIcon(I('tb_folder.png'))
        self.delete_icon = QIcon(I('list_remove.png'))
        self.rename_icon = QIcon(I('edit-undo.png'))

        self._model = TagsModel(self)
        self._model.search_item_renamed.connect(self.search_item_renamed)
        self._model.refresh_required.connect(self.refresh_required,
                type=Qt.QueuedConnection)
        self._model.tag_item_renamed.connect(self.tag_item_renamed)
        self._model.restriction_error.connect(self.restriction_error)
        self._model.user_categories_edited.connect(self.user_categories_edited,
                type=Qt.QueuedConnection)
        self._model.drag_drop_finished.connect(self.drag_drop_finished)
        self.set_look_and_feel()
        # Allowing keyboard focus looks bad in the Qt Fusion style and is useless
        # anyway since the enter/spacebar keys do nothing
        self.setFocusPolicy(Qt.NoFocus)
开发者ID:j-howell,项目名称:calibre,代码行数:38,代码来源:view.py

示例12: dragMoveEvent

 def dragMoveEvent(self, event):
     QTreeView.dragMoveEvent(self, event)
     self.setDropIndicatorShown(False)
     index = self.indexAt(event.pos())
     if not index.isValid():
         return
     src_is_tb = event.mimeData().hasFormat("application/calibre+from_tag_browser")
     item = index.data(Qt.UserRole)
     if item.type == TagTreeItem.ROOT:
         return
     flags = self._model.flags(index)
     if item.type == TagTreeItem.TAG and flags & Qt.ItemIsDropEnabled:
         self.setDropIndicatorShown(not src_is_tb)
         return
     if item.type == TagTreeItem.CATEGORY and not item.is_gst:
         fm_dest = self.db.metadata_for_field(item.category_key)
         if fm_dest["kind"] == "user":
             if src_is_tb:
                 if event.dropAction() == Qt.MoveAction:
                     data = str(event.mimeData().data("application/calibre+from_tag_browser"))
                     src = cPickle.loads(data)
                     for s in src:
                         if s[0] == TagTreeItem.TAG and (not s[1].startswith("@") or s[2]):
                             return
                 self.setDropIndicatorShown(True)
                 return
             md = event.mimeData()
             if hasattr(md, "column_name"):
                 fm_src = self.db.metadata_for_field(md.column_name)
                 if md.column_name in ["authors", "publisher", "series"] or (
                     fm_src["is_custom"]
                     and (
                         (fm_src["datatype"] in ["series", "text", "enumeration"] and not fm_src["is_multiple"])
                         or (fm_src["datatype"] == "composite" and fm_src["display"].get("make_category", False))
                     )
                 ):
                     self.setDropIndicatorShown(True)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:37,代码来源:view.py

示例13: __init__

    def __init__(self, *args):
        QTreeView.__init__(self, *args)
        self.setCursor(Qt.PointingHandCursor)
        self.setMinimumWidth(80)
        self.header().close()
        self.setStyleSheet('''
                QTreeView {
                    background-color: palette(window);
                    color: palette(window-text);
                    border: none;
                }

                QTreeView::item {
                    border: 1px solid transparent;
                    padding-top:0.5ex;
                    padding-bottom:0.5ex;
                }

                QTreeView::item:hover {
                    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
                    border: 1px solid #bfcde4;
                    border-radius: 6px;
                }
        ''')
开发者ID:Cykooz,项目名称:calibre,代码行数:24,代码来源:toc.py

示例14: init_UI

 def init_UI(self):
     """creates the UI
     """
     self.log.debug("Setting up Navigation area UI...")
     self.tree = QTreeView()
     self.tree.doubleClicked.connect(self.onDoubleClick)
     self.grid = QGridLayout()
     self.setLayout(self.grid)
     self.header_lbl = QLabel("Projects and Samples:", self)
     self.header_lbl.setStyleSheet(general.label_style_2nd)
     self.grid.addWidget(self.header_lbl, 0,0)
     
     self.grid.addWidget(self.tree, 1, 0)
     header = self.tree.header()
     header.hide()
     self.log.debug("\t=> Done!")
开发者ID:DKMS-LSL,项目名称:typeloader,代码行数:16,代码来源:GUI_navigation.py

示例15: currentChanged

 def currentChanged(self, current, previous):
     QTreeView.currentChanged(self, current, previous)
     self.parent().current_changed(current, previous)
开发者ID:Farb,项目名称:calibre,代码行数:3,代码来源:scheduler.py


注:本文中的PyQt5.Qt.QTreeView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。