Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QListWidgetItem is not drawn correctly
Forum Updated to NodeBB v4.3 + New Features

QListWidgetItem is not drawn correctly

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 760 Views 2 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.
  • P Offline
    P Offline
    peter-70
    wrote on last edited by peter-70
    #1

    I build up a ruse of CustomWidgets in a QListWidget. So far, it works well.
    A problem occurs when I move the vertical scroll bar downwards and want to display items that were not previously visible.
    Then they are inserted as transparent rectangles, I can click them and respond to the clicks, but they are not drawn. They stay transparent!

    I insert a picture to get a rough idea of the problem: https://ibb.co/Z6dd70X

    In my QListWidget I try to repaint it, but it doesn't work:

    QListWidget::verticalScrollbarValueChanged(value);
    auto item = this->itemAt(QPoint(24, value));
    if (!item)
    {
        return;
    }
    
    auto widget = this->itemWidget(item);
    if (!widget)
    {
        return;
    }
    
    //    widget->resize(widget->size());
    //    widget->repaint();
    widget->update();
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show your original code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        peter-70
        wrote on last edited by
        #3

        What do you want to see? Adding the items, or something else?
        Btw. you see the items, what is the relevance of the adding items code?
        The issue is, the items are not correctly painted, as described above.
        So which part of the code, can I show you?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          peter-70
          wrote on last edited by
          #4

          This is the code where the items are added to the QListWidget:

          void ListControl::AddCustomWidget(QWidget* customWidget, const QSize& size, bool forceSize)
          {
              if (forceSize)
              {
                  customWidget->adjustSize();
              }
          
              auto displaySize = customWidget->size();
              auto width = size.width();
              auto height = size.height();
          
              auto item = new QListWidgetItem(this);
              this->addItem(item);
          
              if (width >= 0)
              {
                  displaySize.setWidth(width);
              }
              else
              {
                  displaySize.setWidth(displaySize.width() - (this->verticalScrollBar()->width() + this->rightSpace));
              }
          
              if (height >= 0)
              {
                  displaySize.setHeight(height);
              }
          
              item->setSizeHint(displaySize);
              this->setItemWidget(item, customWidget);
          }
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Are you sure the size of the widgets are valid when you set them ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • P Offline
              P Offline
              peter-70
              wrote on last edited by
              #6

              Yes, absolutely! I have checked it. Furthermore the items rectangles are drawn, just theirs content isn't

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                What version of Qt are you using ?
                On what platform ?
                Can you provide a minimal compilable example that shows that behaviour ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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