Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ComboBox Of CheckBoxes not working in Qt5
QtWS25 Last Chance

ComboBox Of CheckBoxes not working in Qt5

Scheduled Pinned Locked Moved Unsolved General and Desktop
combobox modelcheckbox
5 Posts 3 Posters 2.8k Views
  • 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.
  • Fahad Al-SaidiF Offline
    Fahad Al-SaidiF Offline
    Fahad Al-Saidi
    wrote on last edited by
    #1

    When I tried this example in Qt5.6 checkboxes doesn’t rendered at all. However, It works fine in Qt4.
    Why ? is it a bug or the behaviour changed in Qt 5? Is there any workaround?

    D 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome
      Worked for me in 5.5 ?

      https://www.dropbox.com/s/zqn043nb7u8629r/testcheck.zip?dl=0

      Fahad Al-SaidiF 1 Reply Last reply
      3
      • Fahad Al-SaidiF Fahad Al-Saidi

        When I tried this example in Qt5.6 checkboxes doesn’t rendered at all. However, It works fine in Qt4.
        Why ? is it a bug or the behaviour changed in Qt 5? Is there any workaround?

        D Offline
        D Offline
        Devopia53
        wrote on last edited by
        #3

        @Fahad-Al-Saidi

        Hi,

        You can very simple implement by Qt5.
        Something like this:

        auto    lw = new QListWidget;
        foreach (auto str, QStringList() << "a" << "b" << "c") {
            auto    li = new QListWidgetItem(str);
        
            li->setFlags(li->flags() | Qt::ItemIsUserCheckable);
            li->setCheckState(Qt::Unchecked);
            lw->addItem(li);
        }
        
        comboBox->setModel(lw->model());
        comboBox->setView(lw);
        
        
        Fahad Al-SaidiF 1 Reply Last reply
        2
        • mrjjM mrjj

          Hi and welcome
          Worked for me in 5.5 ?

          https://www.dropbox.com/s/zqn043nb7u8629r/testcheck.zip?dl=0

          Fahad Al-SaidiF Offline
          Fahad Al-SaidiF Offline
          Fahad Al-Saidi
          wrote on last edited by
          #4

          @mrjj at least under Linux ( kde Linux mint 17.3 ) it doesn't work see
          alt text

          1 Reply Last reply
          0
          • D Devopia53

            @Fahad-Al-Saidi

            Hi,

            You can very simple implement by Qt5.
            Something like this:

            auto    lw = new QListWidget;
            foreach (auto str, QStringList() << "a" << "b" << "c") {
                auto    li = new QListWidgetItem(str);
            
                li->setFlags(li->flags() | Qt::ItemIsUserCheckable);
                li->setCheckState(Qt::Unchecked);
                lw->addItem(li);
            }
            
            comboBox->setModel(lw->model());
            comboBox->setView(lw);
            
            
            Fahad Al-SaidiF Offline
            Fahad Al-SaidiF Offline
            Fahad Al-Saidi
            wrote on last edited by Fahad Al-Saidi
            #5

            @Devopia53 Thanks, the checkboxes are displayed at least but selection by mouse is very difficult. I don't know why. UPDATE I comment out li->flags() and things works fine.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved