Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to draw antialias MapPolyline lines?
Forum Updated to NodeBB v4.3 + New Features

How to draw antialias MapPolyline lines?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 1.6k 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.
  • AlienA Offline
    AlienA Offline
    Alien
    wrote on last edited by
    #1

    Hello,

    How to draw antialias MapPolyline lines? I try smooth : true but it doesn't make any differences!

    Yours,

    ODБOïO 1 Reply Last reply
    0
    • AlienA Alien

      Hello,

      How to draw antialias MapPolyline lines? I try smooth : true but it doesn't make any differences!

      Yours,

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @Alien hi try antialiasing: true

      AlienA 1 Reply Last reply
      0
      • ODБOïO ODБOï

        @Alien hi try antialiasing: true

        AlienA Offline
        AlienA Offline
        Alien
        wrote on last edited by
        #3

        Dear @LeLev ,
        Unfortunately it doesn't work either

        ODБOïO 1 Reply Last reply
        0
        • AlienA Alien

          Dear @LeLev ,
          Unfortunately it doesn't work either

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by ODБOï
          #4

          @Alien you can try enable multisampling on your QtQuick layer like discussed here
          https://stackoverflow.com/questions/48895449/how-do-i-enable-antialiasing-on-qml-shapes

          AlienA 1 Reply Last reply
          0
          • ODБOïO ODБOï

            @Alien you can try enable multisampling on your QtQuick layer like discussed here
            https://stackoverflow.com/questions/48895449/how-do-i-enable-antialiasing-on-qml-shapes

            AlienA Offline
            AlienA Offline
            Alien
            wrote on last edited by Alien
            #5

            @LeLev Thanks for your advise. However ,when I set :

                QSurfaceFormat format;
                format.setSamples(8);
                QSurfaceFormat::setDefaultFormat(format);
            

            in main.cpp on my system (Ubuntu 16.04 LTS QT 5.14.0) the application starts but it doesn't work just show me an still image.
            and when I use :

                    layer.enabled: true
                    layer.samples: 4
            

            on qml side it doesn't work and the shape doesn't appear anti-aliasing.
            even I use 2,4,8 for sampling, still no effect!

            ODБOïO 1 Reply Last reply
            0
            • AlienA Alien

              @LeLev Thanks for your advise. However ,when I set :

                  QSurfaceFormat format;
                  format.setSamples(8);
                  QSurfaceFormat::setDefaultFormat(format);
              

              in main.cpp on my system (Ubuntu 16.04 LTS QT 5.14.0) the application starts but it doesn't work just show me an still image.
              and when I use :

                      layer.enabled: true
                      layer.samples: 4
              

              on qml side it doesn't work and the shape doesn't appear anti-aliasing.
              even I use 2,4,8 for sampling, still no effect!

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #6

              @Alien
              the last solution i have provided worked in my case.
              but i'm on windows

              #include <QGuiApplication>
              #include <QQmlApplicationEngine>
              #include <QSurfaceFormat>
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
              
                  QGuiApplication app(argc, argv);
              
                  QSurfaceFormat format;
                     format.setSamples(8);
                     QSurfaceFormat::setDefaultFormat(format);
              
                  QQmlApplicationEngine engine;
                  const QUrl url(QStringLiteral("qrc:/main.qml"));
                  QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                                   &app, [url](QObject *obj, const QUrl &objUrl) {
                      if (!obj && url == objUrl)
                          QCoreApplication::exit(-1);
                  }, Qt::QueuedConnection);
                  engine.load(url);
                  return app.exec();
              }
              
              
              import QtQuick 2.13
              import QtQuick.Window 2.13
              import QtQuick.Layouts 1.12
              import QtLocation 5.6
              import QtPositioning 5.6
              
              Window {
                  width: 512
                  height: 512
                  visible: true
              
                  Plugin {
                      id: mapPlugin
                      name: "osm" 
              
                  }
              
              
                  Item {
                      id: root
                      anchors.fill: parent
                      layer.enabled: true
                      layer.samples: 4
                    
              
                      Map {
                          anchors.fill: parent
                          plugin: mapPlugin
                          center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                          zoomLevel: 14
                          MapPolyline {
                              line.width: 8
                              line.color: 'green'
                              antialiasing: true
                              smooth: true
              
                              path: [
                                  { latitude: 54.8, longitude: 10.33 },
                                  { latitude: 54.8, longitude: 10.75 },
                                  { latitude: 58.5, longitude: 11 },
                                  { latitude: 59, longitude: 11 }
                              ]
                          }
                      }
                  }
              }
              
              
              
              
              AlienA 1 Reply Last reply
              1
              • ODБOïO ODБOï

                @Alien
                the last solution i have provided worked in my case.
                but i'm on windows

                #include <QGuiApplication>
                #include <QQmlApplicationEngine>
                #include <QSurfaceFormat>
                
                int main(int argc, char *argv[])
                {
                    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                
                    QGuiApplication app(argc, argv);
                
                    QSurfaceFormat format;
                       format.setSamples(8);
                       QSurfaceFormat::setDefaultFormat(format);
                
                    QQmlApplicationEngine engine;
                    const QUrl url(QStringLiteral("qrc:/main.qml"));
                    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                                     &app, [url](QObject *obj, const QUrl &objUrl) {
                        if (!obj && url == objUrl)
                            QCoreApplication::exit(-1);
                    }, Qt::QueuedConnection);
                    engine.load(url);
                    return app.exec();
                }
                
                
                import QtQuick 2.13
                import QtQuick.Window 2.13
                import QtQuick.Layouts 1.12
                import QtLocation 5.6
                import QtPositioning 5.6
                
                Window {
                    width: 512
                    height: 512
                    visible: true
                
                    Plugin {
                        id: mapPlugin
                        name: "osm" 
                
                    }
                
                
                    Item {
                        id: root
                        anchors.fill: parent
                        layer.enabled: true
                        layer.samples: 4
                      
                
                        Map {
                            anchors.fill: parent
                            plugin: mapPlugin
                            center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                            zoomLevel: 14
                            MapPolyline {
                                line.width: 8
                                line.color: 'green'
                                antialiasing: true
                                smooth: true
                
                                path: [
                                    { latitude: 54.8, longitude: 10.33 },
                                    { latitude: 54.8, longitude: 10.75 },
                                    { latitude: 58.5, longitude: 11 },
                                    { latitude: 59, longitude: 11 }
                                ]
                            }
                        }
                    }
                }
                
                
                
                
                AlienA Offline
                AlienA Offline
                Alien
                wrote on last edited by
                #7

                @LeLev Thanks,

                My OS(Ubuntu) might has some problems

                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