Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123827

cannot adjust dash and space properly in setDashPattern

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.5.5-1
    • GUI: Painting
    • None
    • Windows

    Description

       

      issue 1

      qreal pd = p * width(); // Calculate the width of the progress bar        
      QPainter painter(this);
      painter.setRenderHint(QPainter::Antialiasing);        
      QPen pen(Qt::green, 15, Qt::CustomDashLine, Qt::SquareCap, Qt::MiterJoin);
      pen.setDashOffset(0);
      pen.setDashPattern({1,1});
      painter.setPen(pen);        
      painter.drawLine(0, height()/2 , pd, height()/2 );
       

      I have created a Qwidget with width() = 120 in the ui fiile, and i want to set a width for the dash and maintain same length with the dash and space ({1,1}). However, it is found that they are not appeared as expected. They didnt keep the same length of dash and space. (Capture.PNG)

       

      issue 2

              qreal pd = p * width(); // Calculate the width of the progress bar        QPainter painter(this);
              painter.setRenderHint(QPainter::Antialiasing);        // QPen pen(Qt::green, 15, Qt::CustomDashLine, Qt::SquareCap, Qt::MiterJoin);
              QPen pen;
              pen.setColor(QColor("#00cc00"));
              pen.setDashOffset(0);
              pen.setWidth(15);
              pen.setDashPattern({1,2});
              painter.setPen(pen);        painter.drawLine(0, height()/2 , pd, height()/2 ); 

      And if i try to set the width and fine tune the value of setDashPattern, even if the space value is larger than the dash value, it does keep their length correct (Capture2.PNG)

       

      issue 3

      it is weird that the first dash is smaller than the second dash.

       

      Attachments

        1. Capture-1.PNG
          Capture-1.PNG
          0.4 kB
        2. Capture2.PNG
          Capture2.PNG
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vgt Eirik Aavitsland
            sam_1723 edfef fefe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes