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
    https://www.dropbox.com/s/bduz3uvpt7ebma8/dotListWidget.png?dl=0

    Thanks a lot.

        ui->listWidget->setFlow(QListWidget::LeftToRight);
        ui->listWidget->setViewMode(QListWidget::IconMode);
        ui->listWidget->setIconSize(QSize(126,126));
        ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        ui->listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     
        this->setStyleSheet("QMainWindow {background: black;}");
     
        ui->listWidget->setStyleSheet(
          "QListWidget {"
             "border-style: solid;"
             "border-width:1px;"
             "border-color:black;"
             "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->setIcon(icon);
            item->setFlags(item->flags() ^ Qt::ItemIsSelectable);
            ui->listWidget->insertItem(cnt, item);
        }
     
        // http://stackoverflow.com/questions/6337589/qlistwidget-adjust-size-to-content
        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.
    https://www.dropbox.com/sh/g3yedv1iirwel6c/AAAjY0hUUbbZTOFsiRVzpiB7a?dl=0



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.