Qt Forum

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

    Unsolved ComboBox Of CheckBoxes not working in Qt5

    General and Desktop
    combobox model checkbox
    3
    5
    2391
    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.
    • Fahad Al-Saidi
      Fahad Al-Saidi last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi and welcome
        Worked for me in 5.5 ?

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

        Fahad Al-Saidi 1 Reply Last reply Reply Quote 3
        • D
          Devopia53 @Fahad Al-Saidi last edited by

          @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-Saidi 1 Reply Last reply Reply Quote 2
          • Fahad Al-Saidi
            Fahad Al-Saidi @mrjj last edited by

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

            1 Reply Last reply Reply Quote 0
            • Fahad Al-Saidi
              Fahad Al-Saidi @Devopia53 last edited by Fahad Al-Saidi

              @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 Reply Quote 0
              • First post
                Last post