Solved How to draw antialias MapPolyline lines?
-
Hello,
How to draw antialias MapPolyline lines? I try
smooth : true
but it doesn't make any differences!Yours,
-
@Alien hi try antialiasing: true
-
Dear @LeLev ,
Unfortunately it doesn't work either -
@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 -
@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! -
@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 } ] } } } }
-
@LeLev Thanks,
My OS(Ubuntu) might has some problems