Important: Please read the Qt Code of Conduct -

how to remove the small dot when selecting ListWidget

  • hello all,

    I am working with icons with listWidget, and here is my code.
    Would you let me know how I can remove the small dot which the yellow arrow is pointing at?
    When I selected an item, the dot appeared right below the item I selected.

    Please take a look at the image

    Thanks a lot.

        this->setStyleSheet("QMainWindow {background: black;}");
          "QListWidget {"
             "border-style: solid;"
             "background-color: black;"
          "QListWidget::item {"
             "border: 0px solid black;"
        for(int cnt = 0; cnt < 5; ++cnt)
            QListWidgetItem* item = new QListWidgetItem;
            QIcon icon(":/images/HMD.png");
            item->setFlags(item->flags() ^ Qt::ItemIsSelectable);
            ui->listWidget->insertItem(cnt, item);
        ui->listWidget->setFixedSize(ui->listWidget->sizeHintForColumn(0) * ui->listWidget->count() + 3 * ui->listWidget->frameWidth(),
                                     ui->listWidget->sizeHintForRow(0) + 2 * ui->listWidget->frameWidth());

    Here is the source code I am testing with.

  • It appears that

    "QListWidget::item {"
        "border: 0px solid black;"

    Is causing your issue. If you leave out that definition, your artifact will disappear. I am not a specialist with stylesheets, so I cannot tell you why it is that the above rule would lead to the artifact you are getting.

    I understand ::item is mostly used to define additional pseudo-state styles like (e.g. :selected, :checked, etc.). On top of that, your QListWidget::item border is not visible anyway (given 0px width).

    I hope this helps.

Log in to reply