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


Python Qt.QTableView类代码示例

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


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

示例1: initialise

    def initialise (self, univers):
        model = QStandardItemModel (3,1)
    
        i = 0
        for faction in univers.faction_list :
            item = QStandardItem(faction.name)
            item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled);
            item.setData(QtCore.Qt.Unchecked, QtCore.Qt.CheckStateRole);

            model.setItem(i, 0, item)
            i = i + 1

        combo = QComboBox()
        combo.setModel(model)

        list_v = QListView()
        list_v.setModel(model)

        table = QTableView()
        table.setModel(model)

        container = QWidget()
        containerLayout = QVBoxLayout()
        container.setLayout(containerLayout)
        containerLayout.addWidget(combo)
        containerLayout.addWidget(list_v)
        containerLayout.addWidget(table)
开发者ID:cyril711,项目名称:git-MythicWar,代码行数:27,代码来源:filter_view.py

示例2: __init__

 def __init__(self, parent=None):
     QTableView.__init__(self, parent)
     self.rt_delegate = RichTextDelegate(self)
     self.setSelectionMode(self.SingleSelection)
     self.setAlternatingRowColors(True)
     self.setSelectionBehavior(self.SelectRows)
     self.setIconSize(QSize(24, 24))
     self.clicked.connect(self.show_details)
     self.doubleClicked.connect(self.select_index)
     self.setSortingEnabled(True)
开发者ID:j-howell,项目名称:calibre,代码行数:10,代码来源:single_download.py

示例3: __init__

 def __init__(self, model, parent=None):
     QTableView.__init__(self, parent)
     self.setSelectionBehavior(self.SelectRows), self.setSelectionMode(self.ExtendedSelection)
     self.setAlternatingRowColors(True)
     self.setSortingEnabled(True)
     self.proxy = p = ProxyModel(self)
     p.setSourceModel(model)
     self.setModel(p)
     self.doubleClicked.connect(self._double_clicked)
     self.setContextMenuPolicy(Qt.CustomContextMenu)
     self.customContextMenuRequested.connect(self.show_context_menu)
开发者ID:thuvh,项目名称:calibre,代码行数:11,代码来源:reports.py

示例4: keyPressEvent

 def keyPressEvent(self, ev):
     if ev.key() in (Qt.Key_Enter, Qt.Key_Return) and self.state() != self.EditingState:
         ci = self.currentIndex()
         if ci.isValid() and ci.flags() & Qt.ItemIsEditable:
             if self.edit(ci, self.EditKeyPressed, ev):
                 ev.accept()
                 return
     return QTableView.keyPressEvent(self, ev)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:8,代码来源:views.py

示例5: viewportEvent

 def viewportEvent(self, event):
     if (event.type() == event.ToolTip and not gprefs['book_list_tooltips']):
         return False
     try:
         ret = self.gesture_manager.handle_event(event)
     except AttributeError:
         ret = None
     if ret is not None:
         return ret
     return QTableView.viewportEvent(self, event)
开发者ID:jelly,项目名称:calibre,代码行数:10,代码来源:views.py

示例6: keyPressEvent

 def keyPressEvent(self, ev):
     if ev.key() in (Qt.Key_Left, Qt.Key_Right):
         ac = self.MoveDown if ev.key() == Qt.Key_Right else self.MoveUp
         index = self.moveCursor(ac, ev.modifiers())
         if index.isValid() and index != self.currentIndex():
             m = self.selectionModel()
             m.select(index, m.Select|m.Current|m.Rows)
             self.setCurrentIndex(index)
             ev.accept()
             return
     return QTableView.keyPressEvent(self, ev)
开发者ID:j-howell,项目名称:calibre,代码行数:11,代码来源:single_download.py

示例7: moveCursor

 def moveCursor(self, action, modifiers):
     orig = self.currentIndex()
     index = QTableView.moveCursor(self, action, modifiers)
     if action == QTableView.MovePageDown:
         moved = index.row() - orig.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() + rows, index.column())
     elif action == QTableView.MovePageUp:
         moved = orig.row() - index.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() - rows, index.column())
     elif action == QTableView.MoveHome and modifiers & Qt.ControlModifier:
         return self.model().index(0, orig.column())
     elif action == QTableView.MoveEnd and modifiers & Qt.ControlModifier:
         return self.model().index(self.model().rowCount(QModelIndex()) - 1, orig.column())
     return index
开发者ID:newnone,项目名称:calibre,代码行数:24,代码来源:views.py

示例8: scrollContentsBy

 def scrollContentsBy(self, dx, dy):
     # Needed as Qt bug causes headerview to not always update when scrolling
     QTableView.scrollContentsBy(self, dx, dy)
     if dy != 0:
         self.column_header.update()
开发者ID:newnone,项目名称:calibre,代码行数:5,代码来源:views.py

示例9: __init__

    def __init__(self, parent, modelcls=BooksModel, use_edit_metadata_dialog=True):
        QTableView.__init__(self, parent)
        self.default_row_height = self.verticalHeader().defaultSectionSize()
        self.gui = parent
        self.setProperty('highlight_current_item', 150)
        self.row_sizing_done = False
        self.alternate_views = AlternateViews(self)

        if not tweaks['horizontal_scrolling_per_column']:
            self.setHorizontalScrollMode(self.ScrollPerPixel)

        self.setEditTriggers(self.EditKeyPressed)
        if tweaks['doubleclick_on_library_view'] == 'edit_cell':
            self.setEditTriggers(self.DoubleClicked|self.editTriggers())
        elif tweaks['doubleclick_on_library_view'] == 'open_viewer':
            self.setEditTriggers(self.SelectedClicked|self.editTriggers())
            self.doubleClicked.connect(parent.iactions['View'].view_triggered)
        elif tweaks['doubleclick_on_library_view'] == 'edit_metadata':
            # Must not enable single-click to edit, or the field will remain
            # open in edit mode underneath the edit metadata dialog
            if use_edit_metadata_dialog:
                self.doubleClicked.connect(
                        partial(parent.iactions['Edit Metadata'].edit_metadata,
                                checked=False))
            else:
                self.setEditTriggers(self.DoubleClicked|self.editTriggers())

        setup_dnd_interface(self)
        self.setAlternatingRowColors(True)
        self.setShowGrid(False)
        self.setWordWrap(False)

        self.rating_delegate = RatingDelegate(self)
        self.timestamp_delegate = DateDelegate(self)
        self.pubdate_delegate = PubDateDelegate(self)
        self.last_modified_delegate = DateDelegate(self,
                tweak_name='gui_last_modified_display_format')
        self.languages_delegate = LanguagesDelegate(self)
        self.tags_delegate = CompleteDelegate(self, ',', 'all_tag_names')
        self.authors_delegate = CompleteDelegate(self, '&', 'all_author_names', True)
        self.cc_names_delegate = CompleteDelegate(self, '&', 'all_custom', True)
        self.series_delegate = TextDelegate(self)
        self.publisher_delegate = TextDelegate(self)
        self.text_delegate = TextDelegate(self)
        self.cc_text_delegate = CcTextDelegate(self)
        self.cc_enum_delegate = CcEnumDelegate(self)
        self.cc_bool_delegate = CcBoolDelegate(self)
        self.cc_comments_delegate = CcCommentsDelegate(self)
        self.cc_template_delegate = CcTemplateDelegate(self)
        self.cc_number_delegate = CcNumberDelegate(self)
        self.display_parent = parent
        self._model = modelcls(self)
        self.setModel(self._model)
        self._model.count_changed_signal.connect(self.do_row_sizing,
                                                 type=Qt.QueuedConnection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.setSortingEnabled(True)
        self.selectionModel().currentRowChanged.connect(self._model.current_changed)
        self.preserve_state = partial(PreserveViewState, self)
        self.marked_changed_listener = FunctionDispatcher(self.marked_changed)

        # {{{ Column Header setup
        self.can_add_columns = True
        self.was_restored = False
        self.column_header = HeaderView(Qt.Horizontal, self)
        self.setHorizontalHeader(self.column_header)
        self.column_header.sortIndicatorChanged.disconnect()
        self.column_header.sortIndicatorChanged.connect(self.user_sort_requested)
        self.column_header.setSectionsMovable(True)
        self.column_header.setSectionsClickable(True)
        self.column_header.sectionMoved.connect(self.save_state)
        self.column_header.setContextMenuPolicy(Qt.CustomContextMenu)
        self.column_header.customContextMenuRequested.connect(self.show_column_header_context_menu)
        self.column_header.sectionResized.connect(self.column_resized, Qt.QueuedConnection)
        self.row_header = HeaderView(Qt.Vertical, self)
        self.row_header.setSectionResizeMode(self.row_header.Fixed)
        self.setVerticalHeader(self.row_header)
        # }}}

        self._model.database_changed.connect(self.database_changed)
        hv = self.verticalHeader()
        hv.setSectionsClickable(True)
        hv.setCursor(Qt.PointingHandCursor)
        self.selected_ids = []
        self._model.about_to_be_sorted.connect(self.about_to_be_sorted)
        self._model.sorting_done.connect(self.sorting_done,
                type=Qt.QueuedConnection)
开发者ID:newnone,项目名称:calibre,代码行数:87,代码来源:views.py

示例10: user_sort_requested

 def user_sort_requested(self, col, order=Qt.AscendingOrder):
     if col >= len(self.column_map) or col < 0:
         return QTableView.sortByColumn(self, col)
     field = self.column_map[col]
     self.intelligent_sort(field, order == Qt.AscendingOrder)
开发者ID:newnone,项目名称:calibre,代码行数:5,代码来源:views.py

示例11: resizeColumnsToContents

 def resizeColumnsToContents(self):
     QTableView.resizeColumnsToContents(self)
     self.columns_resized = True
开发者ID:newnone,项目名称:calibre,代码行数:3,代码来源:views.py

示例12: viewportEvent

 def viewportEvent(self, event):
     if (event.type() == event.ToolTip and not gprefs['book_list_tooltips']):
         return False
     return QTableView.viewportEvent(self, event)
开发者ID:newnone,项目名称:calibre,代码行数:4,代码来源:views.py

示例13: keyPressEvent

 def keyPressEvent(self, ev):
     if handle_enter_press(self, ev):
         return
     return QTableView.keyPressEvent(self, ev)
开发者ID:jelly,项目名称:calibre,代码行数:4,代码来源:views.py

示例14: keyPressEvent

 def keyPressEvent(self, ev):
     if self.DELETE_POSSIBLE and ev.key() == Qt.Key_Delete:
         self.delete_selected()
         ev.accept()
         return
     return QTableView.keyPressEvent(self, ev)
开发者ID:thuvh,项目名称:calibre,代码行数:6,代码来源:reports.py

示例15: OpdsDialog

class OpdsDialog(QDialog):

    def __init__(self, gui, icon, do_user_config):
        QDialog.__init__(self, gui)
        self.gui = gui
        self.do_user_config = do_user_config

        self.db = gui.current_db.new_api

        # The model for the book list
        self.model = OpdsBooksModel(None, self.dummy_books(), self.db)
        self.searchproxymodel = QSortFilterProxyModel(self)
        self.searchproxymodel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.searchproxymodel.setFilterKeyColumn(-1)
        self.searchproxymodel.setSourceModel(self.model)

        self.layout = QGridLayout()
        self.setLayout(self.layout)

        self.setWindowTitle('OPDS Client')
        self.setWindowIcon(icon)

        labelColumnWidths = []

        self.opdsUrlLabel = QLabel('OPDS URL: ')
        self.layout.addWidget(self.opdsUrlLabel, 0, 0)
        labelColumnWidths.append(self.layout.itemAtPosition(0, 0).sizeHint().width())

        config.convertSingleStringOpdsUrlPreferenceToListOfStringsPreference()
        self.opdsUrlEditor = QComboBox(self)
        self.opdsUrlEditor.activated.connect(self.opdsUrlEditorActivated)
        self.opdsUrlEditor.addItems(prefs['opds_url'])
        self.opdsUrlEditor.setEditable(True)
        self.opdsUrlEditor.setInsertPolicy(QComboBox.InsertAtTop)
        self.layout.addWidget(self.opdsUrlEditor, 0, 1, 1, 3)
        self.opdsUrlLabel.setBuddy(self.opdsUrlEditor)

        buttonColumnNumber = 7
        buttonColumnWidths = []
        self.about_button = QPushButton('About', self)
        self.about_button.setAutoDefault(False)
        self.about_button.clicked.connect(self.about)
        self.layout.addWidget(self.about_button, 0, buttonColumnNumber)
        buttonColumnWidths.append(self.layout.itemAtPosition(0, buttonColumnNumber).sizeHint().width()) 

        # Initially download the catalogs found in the root catalog of the URL
        # selected at startup.  Fail quietly on failing to open the URL
        catalogsTuple = self.model.downloadOpdsRootCatalog(self.gui, self.opdsUrlEditor.currentText(), False)
        print catalogsTuple
        firstCatalogTitle = catalogsTuple[0]
        self.currentOpdsCatalogs = catalogsTuple[1] # A dictionary of title->feedURL

        self.opdsCatalogSelectorLabel = QLabel('OPDS Catalog:')
        self.layout.addWidget(self.opdsCatalogSelectorLabel, 1, 0)
        labelColumnWidths.append(self.layout.itemAtPosition(1, 0).sizeHint().width())

        self.opdsCatalogSelector = QComboBox(self)
        self.opdsCatalogSelector.setEditable(False)
        self.opdsCatalogSelectorModel = QStringListModel(self.currentOpdsCatalogs.keys())
        self.opdsCatalogSelector.setModel(self.opdsCatalogSelectorModel)
        self.opdsCatalogSelector.setCurrentText(firstCatalogTitle)
        self.layout.addWidget(self.opdsCatalogSelector, 1, 1, 1, 3)

        self.download_opds_button = QPushButton('Download OPDS', self)
        self.download_opds_button.setAutoDefault(False)
        self.download_opds_button.clicked.connect(self.download_opds)
        self.layout.addWidget(self.download_opds_button, 1, buttonColumnNumber)
        buttonColumnWidths.append(self.layout.itemAtPosition(1, buttonColumnNumber).sizeHint().width()) 

        # Search GUI
        self.searchEditor = QLineEdit(self)
        self.searchEditor.returnPressed.connect(self.searchBookList)
        self.layout.addWidget(self.searchEditor, 2, buttonColumnNumber - 2, 1, 2)

        self.searchButton = QPushButton('Search', self)
        self.searchButton.setAutoDefault(False)
        self.searchButton.clicked.connect(self.searchBookList)
        self.layout.addWidget(self.searchButton, 2, buttonColumnNumber)
        buttonColumnWidths.append(self.layout.itemAtPosition(2, buttonColumnNumber).sizeHint().width())

        # The main book list
        self.library_view = QTableView(self)
        self.library_view.setAlternatingRowColors(True)
        self.library_view.setModel(self.searchproxymodel)
        self.library_view.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
        self.library_view.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        self.library_view.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
        self.library_view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.resizeAllLibraryViewLinesToHeaderHeight()
        self.library_view.resizeColumnsToContents()
        self.layout.addWidget(self.library_view, 3, 0, 3, buttonColumnNumber + 1)

        self.hideNewsCheckbox = QCheckBox('Hide Newspapers', self)
        self.hideNewsCheckbox.clicked.connect(self.setHideNewspapers)
        self.hideNewsCheckbox.setChecked(prefs['hideNewspapers'])
        self.layout.addWidget(self.hideNewsCheckbox, 6, 0, 1, 3)

        self.hideBooksAlreadyInLibraryCheckbox = QCheckBox('Hide books already in library', self)
        self.hideBooksAlreadyInLibraryCheckbox.clicked.connect(self.setHideBooksAlreadyInLibrary)
        self.hideBooksAlreadyInLibraryCheckbox.setChecked(prefs['hideBooksAlreadyInLibrary'])
#.........这里部分代码省略.........
开发者ID:sbobovyc,项目名称:opds-reader,代码行数:101,代码来源:main.py


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