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

  • Home
  • SEARCH
  • 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 6989457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:12:52+00:00 2026-05-27T19:12:52+00:00

Currently I have a simple setup where I maintain a list of bools corresponding

  • 0

Currently I have a simple setup where I maintain a list of bools corresponding to each item in my ListModel:

http://programmingexamples.net/wiki/Qt/ModelView/StringListModelCheckable

However, now what I want to do is have two such lists bools, say IsHot and IsLarge. Then I want to have a ListView that displays each string with a checkbox for one of the bools (the “Hot” view), and a separate ListView that displays each string with a checkbox for the other bool (the “Large” bool). Any hints on how to go about this?

  • 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-05-27T19:12:53+00:00Added an answer on May 27, 2026 at 7:12 pm

    Make your model a table, return the data in two different columns, the cells in these columns will be checkable.

    On your list views, call QListView::setModelColumn to set the column the list view displays.

    If you want to synchronise scrolling between the lists, you would then be better using a QTableView, so that rows would match up.


    Edit to add more detail on returning text and check state.

    To return a text and the state of a checkbox from the model you return different data for different roles from the [data] function on your model.

    From the manual for Qt::ItemDataRole:

    Qt::DisplayRole The key data to be rendered in the form of text. (QString)
    Qt::CheckStateRole This role is used to obtain the checked state of an item. (Qt::CheckState)

    Both columns in your model would return the same data (the name) for DisplayRole but different data for CheckStateRole

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

Sidebar

Related Questions

Currently I have this setup in our simple-hosts.conf: url.rewrite-once = ( .*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$ => $0,
I currently have a simple form that when you click the save button will
There is probably is simple fix for this but I currently have code similar
I have a simple ticket logging application build on LAMP. I am currently playing
I am currently learning F# and have tried (an extremely) simple example of FizzBuzz.
Currently, I have some basic code to play a simple tone whenever a button
I have been trying to get more in to TDD. Currently keeping it simple
I'm working on a relatively simple website with (currently) a single resource. I have
The Setup: I currently have a page with a GridView control on it inside
I currently have an ASP.NET MVC application that exists. I want to add a

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.