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.
  • F Offline
    F Offline
    Fahad Al-Saidi
    wrote on 25 May 2016, 05:08 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 25 May 2016, 07:46
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 25 May 2016, 06:51 last edited by
      #2

      Hi and welcome
      Worked for me in 5.5 ?

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

      F 1 Reply Last reply 25 May 2016, 10:48
      3
      • F Fahad Al-Saidi
        25 May 2016, 05:08

        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 25 May 2016, 07:46 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);
        
        
        F 1 Reply Last reply 25 May 2016, 11:09
        2
        • M mrjj
          25 May 2016, 06:51

          Hi and welcome
          Worked for me in 5.5 ?

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

          F Offline
          F Offline
          Fahad Al-Saidi
          wrote on 25 May 2016, 10:48 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
            25 May 2016, 07:46

            @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);
            
            
            F Offline
            F Offline
            Fahad Al-Saidi
            wrote on 25 May 2016, 11:09 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

            3/5

            25 May 2016, 07:46

            • Login

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