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. how to remove the small dot when selecting ListWidget

how to remove the small dot when selecting ListWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 827 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.
  • sehnkimS Offline
    sehnkimS Offline
    sehnkim
    wrote on last edited by sehnkim
    #1

    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

    1 Reply Last reply
    0
    • VagabondV Offline
      VagabondV Offline
      Vagabond
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1

      • Login

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