Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [PyQt] QtableView Header. How to add top-right small button to hide/show column with checked/unchecked Checkboxes?

    Language Bindings
    2
    3
    4707
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      Ithrayen last edited by

      With PyQt4, I am using a QtableView with more than 10 columns. The user must have the choice of showing/hiding a column.

      This is generally done by adding a small button in the top-right of the table's header. The button shows a menu with checked/unchecked Checkboxes allowing to hide/show columns.

      This is an example of a Sqlite-Manager Table :http://williamsportwebdeveloper.com/cgi/wp/wp-content/uploads/2010/08/SQLiteManager.png.

      So, I wonder how can I do the same with PyQt's QtableView?

      Thanks,

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        I have not used PyQt. From Qt C++ perspective, you can get Header view for TableView and implement your own delegate to have checkboxes. Based on the actions on the delegate you can hide/show columns you want.

        Another possibility is to make two components separately

        1. Header Component and View Component
        2. Show them in vertical layout. You can handle the action of header component.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 0
        • I
          Ithrayen last edited by

          Thanks Dheerendra,

          A solution was proposed "here":http://stackoverflow.com/questions/25744109/pyqt-qtableview-header-how-to-add-top-right-small-button-to-hide-show-column-wi/25752676?noredirect=1#comment40275860_25752676.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post