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 list view item dot line ? i had searched and try some ways but not work.

How to remove list view item dot line ? i had searched and try some ways but not work.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.5k Views 1 Watching
  • 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.
  • joeQJ Offline
    joeQJ Offline
    joeQ
    wrote on last edited by joeQ
    #1

    In the list view, when the item get the focus or selected, and there is one dot line over the item.
    i used the delegate to repainter the item. like the image:
    My problem

    but the dot line ...

    I also know many people had the question. and i also try some ways, such:

    setStyleSheet("QListView::item:focus{border:none;}");
    setStyleSheet("QListView::item:focus{outline:none;}");
    setStyleSheet("QListView::item:focus{outline:0px;}");
    setStyleSheet("QListView::item{border:none;}");
    setStyleSheet("QListView::item{outline:none;}");
    setStyleSheet("QListView::item{outline:0px;}");
    

    They are all failed! I want to cry...

    I also saw the topic qt fourm topic

    Just do it!

    1 Reply Last reply
    0
    • joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by joeQ
      #4

      Haha, I solved my problem. O(∩_∩)O~~, Just easy. Use the delegate and then.

      void StyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
      {
          /** some code at here */
      
          qDebug() << option.showDecorationSelected; // --------------------false
          
           pen = painter->pen();
          
          if( option.state & QStyle::State_Selected )
          {
              pen.setColor( QColor(65,105,255) );
          }
          else
          {
              pen.setColor( QColor(211,211,211) );
          }
      
          /**  some code at here */
          /** QStyledItemDelegate::paint(painter, option, index); */  // **don't need this line code.** 
      }
      

      In the StyledItemDelegate::paint function, we don't add this line code QStyledItemDelegate::paint(painter, option, index);

      OK, If some one also has the problem, can tell me.

      Just do it!

      1 Reply Last reply
      1
      • m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by
        #2

        Hi,
        Have you tried to set option.showDecorationSelected=false via QStyledItemDelegate::initStyleOption(). According to the docu of QStyledItemDelegate::paint this seems to be an option for this kind of changes.
        -Michael.

        joeQJ 2 Replies Last reply
        1
        • m.sueM m.sue

          Hi,
          Have you tried to set option.showDecorationSelected=false via QStyledItemDelegate::initStyleOption(). According to the docu of QStyledItemDelegate::paint this seems to be an option for this kind of changes.
          -Michael.

          joeQJ Offline
          joeQJ Offline
          joeQ
          wrote on last edited by joeQ
          #3

          @m.sue

          I saw the Qt manual. Found QStyleOptionViewItem::showDecorationSelected

          bool QStyleOptionViewItem::showDecorationSelected
          This variable holds whether the decoration should be highlighted on selected items.
          If this option is true, the branch and any decorations on selected items should be highlighted, indicating that the item is selected; otherwise, no highlighting is required. The default value is false.

          And, I qDebug the value in my code; It is false. It doesn't solve my problem.

          void StyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
          {
              /** some code at here */
          
              qDebug() << option.showDecorationSelected; // --------------------false
              
               pen = painter->pen();
              
              if( option.state & QStyle::State_Selected )
              {
                  pen.setColor( QColor(65,105,255) );
              }
              else
              {
                  pen.setColor( QColor(211,211,211) );
              }
          
              /**  some code at here */
              QStyledItemDelegate::paint(painter, option, index);
          }
          
          

          Just do it!

          1 Reply Last reply
          0
          • joeQJ Offline
            joeQJ Offline
            joeQ
            wrote on last edited by joeQ
            #4

            Haha, I solved my problem. O(∩_∩)O~~, Just easy. Use the delegate and then.

            void StyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
            {
                /** some code at here */
            
                qDebug() << option.showDecorationSelected; // --------------------false
                
                 pen = painter->pen();
                
                if( option.state & QStyle::State_Selected )
                {
                    pen.setColor( QColor(65,105,255) );
                }
                else
                {
                    pen.setColor( QColor(211,211,211) );
                }
            
                /**  some code at here */
                /** QStyledItemDelegate::paint(painter, option, index); */  // **don't need this line code.** 
            }
            

            In the StyledItemDelegate::paint function, we don't add this line code QStyledItemDelegate::paint(painter, option, index);

            OK, If some one also has the problem, can tell me.

            Just do it!

            1 Reply Last reply
            1
            • m.sueM m.sue

              Hi,
              Have you tried to set option.showDecorationSelected=false via QStyledItemDelegate::initStyleOption(). According to the docu of QStyledItemDelegate::paint this seems to be an option for this kind of changes.
              -Michael.

              joeQJ Offline
              joeQJ Offline
              joeQ
              wrote on last edited by
              #5

              @m.sue Think you very much. I get it.

              Just do it!

              1 Reply Last reply
              0

              • Login

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