Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:55:16+00:00 2026-06-15T10:55:16+00:00

I am trying to restrict selection of a tree to a particular column. I

  • 0

I am trying to restrict selection of a tree to a particular column.

I am using delegates heavily to create custom per-item-per-column behaviors, editors, etc. I was hoping I could somehow do this from a delegate by blocking an event or something similar. The problem is, I think i would have to create an entirely custom solution that mimics extended selection.

However, after a lot of searching and very few examples, it sounds like I want a custom QItemSelectionModel on my tree view. Is this assumption correct?

How do I create a custom QItemSelectionModel that will use the Extended Selection Mode but allow me to ignore or revert a selection if not in a particular column. In other words, clicking on another column should not change the selection (should not select or deselect)

I know how to add the selection model once I have it. I am asking for help implementing the derived class (unless this can be done with a connected signal).

I am using Python, but would value any help.

Thank you,

[EDIT:] I found these similar questions:
http://lists.qt.nokia.com/pipermail/qt-interest/2010-September/027647.html

“Subclass QItemSelectionModel and reimplement both select methods to have the
behaviour you want.
Just ignore the parts of ranges with column > 0.
…
Or maybe just reimplement flags() to make the item not selectable. I don’t
know if that will have any side effects.”

I tried reimplementing flags on my QTreeWidgetItem, but it never got called:

def flags(self, index):
    print index.column()
    return super(DDOutlinerBaseItem, self).flags(index)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:55:17+00:00Added an answer on June 15, 2026 at 10:55 am

    The following adjustment should work, in theory.

    The above solution could use two separate methods and @pyqtSlot decorators to disambiguate the overloaded method names:

    @pyqtSlot(QModelIndex, QItemSelectionModel.SelectionFlags)
      def select(self, index, command):
        # ...
    
    @pyqtSlot(QItemSelection, QItemSelectionModel.SelectionFlags)
      def select(self, selection, command):
        #...
    

    This avoids the need to check for instances of certain classes in the method implementations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a symmetric key in SQL Server 2005 and restrict it
Possible Duplicate: before_filter :require_owner I am trying to restrict access to certain actions using
Using geolocation data of websocket users on a specific server, I'm trying to restrict
I am trying to restrict the permissions my assembly has using Security Declarations. I
I'm trying to restrict the selectable values of a 'persons' field in a particular
I am trying to create a Custom control specifically for my application which would
I'm trying to create a Service using Automator that simply calls textutil convert. Eventually,
I'm using rails 3 and Devise and i'm trying to restrict some actions to
I'm using haystack with whoosh, trying to restrict search results to entries created by
I was trying to restrict the scope of an NSMetadataQuery item. I know there's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.