get windows preview image for a file
-
Hi
I have not seen any Qt way, however, you can use native API to do it
https://code.msdn.microsoft.com/windowsapps/File-thumbnails-sample-17575959
there is c++ sample.update:
you could also maybe cheat a bit and use
https://thumbcacheviewer.github.io/
as it has a cmd line version so maybe you could run
it on a folder (using QProcess) and export the images to files.
Not tested if possible. was just a thought. -
Hi
I have not seen any Qt way, however, you can use native API to do it
https://code.msdn.microsoft.com/windowsapps/File-thumbnails-sample-17575959
there is c++ sample.update:
you could also maybe cheat a bit and use
https://thumbcacheviewer.github.io/
as it has a cmd line version so maybe you could run
it on a folder (using QProcess) and export the images to files.
Not tested if possible. was just a thought.@mrjj thank you very much I will dig these 2 potential solutions.
my final goal is to click on a file and see its preview in my quick app, so more natual solution is to integrate a gcode viewer in my app instead of using the os things but i could not find any gcode parser/viewer that i m able to integrate. do you know one ?
-
@mrjj thank you very much I will dig these 2 potential solutions.
my final goal is to click on a file and see its preview in my quick app, so more natual solution is to integrate a gcode viewer in my app instead of using the os things but i could not find any gcode parser/viewer that i m able to integrate. do you know one ?
@LeLev
So for what is available would Googlinggcode viewer source code
and looking at some of those hopefully give you some C++ source you can use? https://github.com/jtronics/G-Code-jViewer actually says it'sQT
-based, I'm hoping it's reallyQt
-based :) -
@LeLev
So for what is available would Googlinggcode viewer source code
and looking at some of those hopefully give you some C++ source you can use? https://github.com/jtronics/G-Code-jViewer actually says it'sQT
-based, I'm hoping it's reallyQt
-based :)@JonB thank you
i tryed 4 or 5 things and shamefully failed to integrate with my project as i said... I heve one Gcode to segment js library and im planning to use it with qml canvas 2d to draw the path.I just wanted to see if someone knows a ready to use solution, who knows with Qt..! i already had nice surprises with @SGaist suggesting qvncclient or the arrival of qtopcua..
-
@LeLev
So for what is available would Googlinggcode viewer source code
and looking at some of those hopefully give you some C++ source you can use? https://github.com/jtronics/G-Code-jViewer actually says it'sQT
-based, I'm hoping it's reallyQt
-based :) -
hi,i found this project. It works wery well. The only problem is i cant figure out how to use just a little part of it (open file and generate a preview) in my app,
Could you please give a hint on how to integrate it with my qt quick project ?
https://github.com/zapmaker/GrblHoming.git
i would like to create mu QQuickPaintedItem that shows the preview
thank you -
i try to link the GrblHoming project to mine, only by
INCLUDEPATH += c:/users/lev/documents/dev/GrblHoming
there is a RenderArea class in GrblHoming project, im trying to create my own render area with QQuickPaintedItem base class
#ifndef GCODEVIEW_H #define GCODEVIEW_H #include <QtQuick/QQuickPaintedItem> #include "renderarea.h" #include "positem.h" #include "renderitemlist.h" class GCodeView : public QQuickPaintedItem { public: GCodeView(QQuickItem *parent = 0); public slots: void setItems(QList<PosItem>); void setLivePoint(double x, double y, bool isMM, bool isLiveCP); void setVisualLivenessCurrPos(bool isLiveCP); void setVisCurrLine(int currLine); protected: void paintEvent(QPaintEvent *event); private: QList<PosItem> items; RenderItemList listToRender; QPen penProposedPath, penAxes, penCoveredPath, penCurrPosActive, penCurrPosInactive, penMeasure; PosItem livePoint; bool isLiveCurrPos; }; #endif // GCODEVIEW_H //.cpp #include "gcodeview.h" #include <QPainter> GCodeView::GCodeView(QQuickItem *parent): QQuickPaintedItem(parent) {} void GCodeView::setItems(QList<PosItem> itemsRcvd) { items = itemsRcvd; listToRender.setCurrFileLine(0); listToRender.convertList(items); listToRender.updateLivePoint(); update(); } void GCodeView::setLivePoint(double x, double y, bool mm, bool isLiveCP) { isLiveCurrPos = isLiveCP; livePoint.setCoords(x, y, mm); listToRender.setLivePoint(livePoint); update(); } void GCodeView::setVisualLivenessCurrPos(bool isLiveCP) { isLiveCurrPos = isLiveCP; } void GCodeView::setVisCurrLine(int currLine) { if (listToRender.setCurrFileLine(currLine)) update(); } void GCodeView::paintEvent(QPaintEvent * /* event */) { if (!items.size()) return; QSize size(this->size().height(),this->size().width()); listToRender.rescale(size); QPainter painter; painter.setPen(penProposedPath); listToRender.writePath(painter, false); painter.setPen(penAxes); listToRender.drawAxes(painter); painter.setPen(penMeasure); listToRender.drawMeasurements(painter); painter.setPen(penCoveredPath); listToRender.writePath(painter, true); //if (!livePoint.isNull()) FIX isNull { if (isLiveCurrPos) painter.setPen(penCurrPosActive); else painter.setPen(penCurrPosInactive); listToRender.drawPoint(painter, livePoint); } }
but this causes compil errors even if i don't use this class yet
gcodeview.obj:-1: erreur : LNK2019: symbole unresolved "public: __cdecl RenderItemList::RenderItemList(void)" (??0RenderItemList@@QEAA@XZ) référencé dans la fonction "public: __cdecl GCodeView::GCodeView(class QQuickItem *)" (??0GCodeView@@QEAA@PEAVQQuickItem@@@Z) gcodeview.obj:-1: erreur : LNK2019: symbole externe non résolu "public: virtual __cdecl RenderItemList::~RenderItemList(void)" (??1RenderItemList@@UEAA@XZ) référencé dans la fonction "int `public: __cdecl GCodeView::GCodeView(class QQuickItem *)'::`1'::dtor$2" (?dtor$2@?0???0GCodeView@@QEAA@PEAVQQuickItem@@@Z@4HA) gcodeview.obj:-1: erreur : LNK2019: symbole externe non résolu "public: void __cdecl RenderItemList::convertList(class QList<class PosItem> const &)" (?convertList@RenderItemList@@QEAAXAEBV?$QList@VPosItem@@@@@Z) référencé dans la fonction "public: void __cdecl GCodeView::setItems(class QList<class PosItem>)" (?setItems@GCodeView@@QEAAXV?$QList@VPosItem@@@@@Z)
-
Hi
Did you also take renderitemlist.cpp and added to your project ?
Just seems like normal linker errors as it sees the stuff in .h but finds no
body/implementation fo rit. -
Hi
Did you also take renderitemlist.cpp and added to your project ?
Just seems like normal linker errors as it sees the stuff in .h but finds no
body/implementation fo rit. -
Hi
Did you also take renderitemlist.cpp and added to your project ?
Just seems like normal linker errors as it sees the stuff in .h but finds no
body/implementation fo rit.@mrjj i have no more linkage errors, but i cant use qmlRegisterType() to expose my class to qml
qmlRegisterType<GCodeView>("GC", 1 ,0 , "gcode");
i have erros saying C:\Qt\5.13.0\msvc2017_64\include\QtQml\qqmlprivate.h:124: error: C2259: 'QQmlPrivate::QQmlElement<T>'ÿ: impossible to create an object from abstract class
with
[
T=GCodeView
]this i smy class
#ifndef GCODEVIEW_H #define GCODEVIEW_H #include <QtQuick/QQuickPaintedItem> //#include "renderarea.h" #include "positem.h" #include "renderitemlist.h" class GCodeView : public QQuickPaintedItem { public: GCodeView(QQuickItem *parent = 0); public slots: void setItems(QList<PosItem>); void setLivePoint(double x, double y, bool isMM, bool isLiveCP); void setVisualLivenessCurrPos(bool isLiveCP); void setVisCurrLine(int currLine); protected: void paint(); private: QList<PosItem> items; RenderItemList listToRender; QPen penProposedPath, penAxes, penCoveredPath, penCurrPosActive, penCurrPosInactive, penMeasure; PosItem livePoint; bool isLiveCurrPos; }; #endif // GCODEVIEW_H //-------------------------------------------------CPP---------------------------------------- #include "gcodeview.h" #include <QPainter> GCodeView::GCodeView(QQuickItem *parent): QQuickPaintedItem(parent) { } void GCodeView::setItems(QList<PosItem> itemsRcvd) { items = itemsRcvd; listToRender.setCurrFileLine(0); listToRender.convertList(items); listToRender.updateLivePoint(); update(); } void GCodeView::setLivePoint(double x, double y, bool mm, bool isLiveCP) { isLiveCurrPos = isLiveCP; livePoint.setCoords(x, y, mm); listToRender.setLivePoint(livePoint); update(); } void GCodeView::setVisualLivenessCurrPos(bool isLiveCP) { isLiveCurrPos = isLiveCP; } void GCodeView::setVisCurrLine(int currLine) { if (listToRender.setCurrFileLine(currLine)) update(); } void GCodeView::paint(/*QPaintEvent */ /* event */) { if (!items.size()) return; QSize size(this->size().height(),this->size().width()); listToRender.rescale(size); QPainter painter; painter.setPen(penProposedPath); listToRender.writePath(painter, false); painter.setPen(penAxes); listToRender.drawAxes(painter); painter.setPen(penMeasure); listToRender.drawMeasurements(painter); painter.setPen(penCoveredPath); listToRender.writePath(painter, true); //if (!livePoint.isNull()) FIX isNull { if (isLiveCurrPos) painter.setPen(penCurrPosActive); else painter.setPen(penCurrPosInactive); listToRender.drawPoint(painter, livePoint); } }
-
@mrjj i have no more linkage errors, but i cant use qmlRegisterType() to expose my class to qml
qmlRegisterType<GCodeView>("GC", 1 ,0 , "gcode");
i have erros saying C:\Qt\5.13.0\msvc2017_64\include\QtQml\qqmlprivate.h:124: error: C2259: 'QQmlPrivate::QQmlElement<T>'ÿ: impossible to create an object from abstract class
with
[
T=GCodeView
]this i smy class
#ifndef GCODEVIEW_H #define GCODEVIEW_H #include <QtQuick/QQuickPaintedItem> //#include "renderarea.h" #include "positem.h" #include "renderitemlist.h" class GCodeView : public QQuickPaintedItem { public: GCodeView(QQuickItem *parent = 0); public slots: void setItems(QList<PosItem>); void setLivePoint(double x, double y, bool isMM, bool isLiveCP); void setVisualLivenessCurrPos(bool isLiveCP); void setVisCurrLine(int currLine); protected: void paint(); private: QList<PosItem> items; RenderItemList listToRender; QPen penProposedPath, penAxes, penCoveredPath, penCurrPosActive, penCurrPosInactive, penMeasure; PosItem livePoint; bool isLiveCurrPos; }; #endif // GCODEVIEW_H //-------------------------------------------------CPP---------------------------------------- #include "gcodeview.h" #include <QPainter> GCodeView::GCodeView(QQuickItem *parent): QQuickPaintedItem(parent) { } void GCodeView::setItems(QList<PosItem> itemsRcvd) { items = itemsRcvd; listToRender.setCurrFileLine(0); listToRender.convertList(items); listToRender.updateLivePoint(); update(); } void GCodeView::setLivePoint(double x, double y, bool mm, bool isLiveCP) { isLiveCurrPos = isLiveCP; livePoint.setCoords(x, y, mm); listToRender.setLivePoint(livePoint); update(); } void GCodeView::setVisualLivenessCurrPos(bool isLiveCP) { isLiveCurrPos = isLiveCP; } void GCodeView::setVisCurrLine(int currLine) { if (listToRender.setCurrFileLine(currLine)) update(); } void GCodeView::paint(/*QPaintEvent */ /* event */) { if (!items.size()) return; QSize size(this->size().height(),this->size().width()); listToRender.rescale(size); QPainter painter; painter.setPen(penProposedPath); listToRender.writePath(painter, false); painter.setPen(penAxes); listToRender.drawAxes(painter); painter.setPen(penMeasure); listToRender.drawMeasurements(painter); painter.setPen(penCoveredPath); listToRender.writePath(painter, true); //if (!livePoint.isNull()) FIX isNull { if (isLiveCurrPos) painter.setPen(penCurrPosActive); else painter.setPen(penCurrPosInactive); listToRender.drawPoint(painter, livePoint); } }
@LeLev said in get windows preview image for a file:
QQuickPaintedItem
Override paint() method correctly. It is pure virtual in QQuickPaintedItem and you overloaded it instead of overriding it (it has aparameter: https://doc.qt.io/qt-5/qquickpainteditem.html#paint).
-
@LeLev said in get windows preview image for a file:
QQuickPaintedItem
Override paint() method correctly. It is pure virtual in QQuickPaintedItem and you overloaded it instead of overriding it (it has aparameter: https://doc.qt.io/qt-5/qquickpainteditem.html#paint).
nice! now my class works nicely ! thank you @mrjj @JonB @jsulm !
edit : im able to display my GCodeView in qml with some test data like :
list.append(PosItem(1,5,4,5)); list.append(PosItem(2,8,1,2)); list.append(PosItem(4,10,1,0)); list.append(PosItem(22,11,5,1));
Now i need to parse a file instead of this test data. sadly i have to make a new post for this because i have an issue in my parse method
#ifndef GCODEVIEW_H #define GCODEVIEW_H #include <QtQuick/QQuickPaintedItem> //#include "renderarea.h" #include "positem.h" #include "renderitemlist.h" class GCodeView : public QQuickPaintedItem { public: GCodeView(QQuickItem *parent = 0); public slots: void setItems(QList<PosItem>); void setLivePoint(double x, double y, bool isMM, bool isLiveCP); void setVisualLivenessCurrPos(bool isLiveCP); void setVisCurrLine(int currLine); protected: void paint( QPainter *painterp); private: QList<PosItem> items; RenderItemList listToRender; QPen penProposedPath, penAxes, penCoveredPath, penCurrPosActive, penCurrPosInactive, penMeasure; PosItem livePoint; bool isLiveCurrPos; }; #endif // GCODEVIEW_H //-----------------------------------------------CPP--------------------------------------------- #include "gcodeview.h" #include <QPainter> GCodeView::GCodeView(QQuickItem *parent): QQuickPaintedItem(parent) { QList<PosItem> list; // some simulation data list.append(PosItem(1,5,4,5)); list.append(PosItem(2,8,1,2)); list.append(PosItem(4,10,1,0)); list.append(PosItem(22,11,5,1)); list.append(PosItem(1,5,4,5)); list.append(PosItem(2,8,1,2)); list.append(PosItem(4,10,1,0)); list.append(PosItem(22,11,5,1)); list.append(PosItem(1,5,4,5)); list.append(PosItem(2,8,1,2)); list.append(PosItem(4,10,1,0)); list.append(PosItem(22,11,5,1)); setItems(list); } void GCodeView::setItems(QList<PosItem> itemsRcvd) { items = itemsRcvd; listToRender.setCurrFileLine(0); listToRender.convertList(items); listToRender.updateLivePoint(); update(); } void GCodeView::setLivePoint(double x, double y, bool mm, bool isLiveCP) { isLiveCurrPos = isLiveCP; livePoint.setCoords(x, y, mm); listToRender.setLivePoint(livePoint); update(); } void GCodeView::setVisualLivenessCurrPos(bool isLiveCP) { isLiveCurrPos = isLiveCP; } void GCodeView::setVisCurrLine(int currLine) { if (listToRender.setCurrFileLine(currLine)) update(); } void GCodeView::paint(QPainter *painter) { if (!items.size()) return; QSize size(this->size().height(),this->size().width()); listToRender.rescale(size); //QPainter painter; painter->setPen(penProposedPath); listToRender.writePath(*painter, false); painter->setPen(penAxes); listToRender.drawAxes(*painter); painter->setPen(penMeasure); listToRender.drawMeasurements(*painter); painter->setPen(penCoveredPath); listToRender.writePath(*painter, true); //if (!livePoint.isNull()) FIX isNull { if (isLiveCurrPos) painter->setPen(penCurrPosActive); else painter->setPen(penCurrPosInactive); listToRender.drawPoint(*painter, livePoint); } } //----------------------------------------------------------------------------------- qmlRegisterType<GCodeView>("GCodeView", 1 ,0 , "Gcode"); //---------------------------------------QML----------------------------------------- import GCodeView 1.0 import "." ApplicationWindow { id: rootmain visible: true Gcode{ anchors.centerIn: parent height: 150 width: 150 } }