Skip to content
QtWS25 Last Chance
  • Save whole context

    Unsolved QML and Qt Quick save load program context storage
    4
    0 Votes
    4 Posts
    941 Views
    ODБOïO
    @BzhAx hi, @BzhAx said in Save whole context: I don't know if this is the best way to do it.. it works ? do you have errors ? You can have your TabButtons in ListModel and use this method : https://stackoverflow.com/questions/48730166/how-to-save-and-restore-the-content-of-a-listmodel?rq=1
  • OpenGL context and testing with catch2

    Unsolved General and Desktop test opengl context
    1
    0 Votes
    1 Posts
    613 Views
    No one has replied
  • 0 Votes
    6 Posts
    3k Views
    M
    OH Thx a lot that was it. Without the const, it works. So my code went from void AnotherClass::showInfo(MyClass const *item) { // Same stuff as above (2nd post) } to void AnotherClass::showInfo(MyClass *item) { // Same stuff as above (2nd post) }
  • Clip QML Types with Context2D

    Unsolved QML and Qt Quick context canvas image qml types
    4
    0 Votes
    4 Posts
    3k Views
    ?
    Out of curiosity, I implemented a QQuickPaintedItem-based PathMask type. The result looks like this: [image: Path_Mask.png] The code is: pathmask.h #ifndef PATHMASK_H #define PATHMASK_H #include <QObject> #include <QQuickItem> #include <QQuickPaintedItem> #include <QPainter> #include <QPainterPath> class PathMask : public QQuickPaintedItem { Q_OBJECT public: explicit PathMask(QQuickItem *parent = Q_NULLPTR); ~PathMask(); virtual void paint(QPainter *painter); Q_INVOKABLE void beginPath(); Q_INVOKABLE void moveTo(qreal x, qreal y); Q_INVOKABLE void lineTo(qreal x, qreal y); Q_INVOKABLE void closePath(); private: QPainterPath *m_path{Q_NULLPTR}; }; #endif // PATHMASK_H pathmask.cpp #include "pathmask.h" #include <QPainterPath> #include <QtMath> PathMask::PathMask(QQuickItem *parent) : QQuickPaintedItem(parent) { } PathMask::~PathMask() { delete m_path; } void PathMask::paint(QPainter *painter) { if (m_path) { painter->setRenderHint(QPainter::Antialiasing); painter->setBrush( QBrush(QColor("black")) ); painter->drawPath( *m_path ); } } void PathMask::beginPath() { delete m_path; m_path = new QPainterPath; update(); } void PathMask::moveTo(qreal x, qreal y) { Q_ASSERT(m_path); m_path->moveTo(x,y); } void PathMask::lineTo(qreal x, qreal y) { Q_ASSERT(m_path); m_path->lineTo(x, y); } void PathMask::closePath() { Q_ASSERT(m_path); m_path->closeSubpath(); update(); } main.qml import QtQuick 2.5 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import QtGraphicalEffects 1.0 import io.qt.forum 1.0 ApplicationWindow { title: "PathMask Demo" visible: true width: 400 height: 400 color: "black" Image { id: src anchors.fill: parent visible: false source: "file:///home/patrick/Downloads/f22.jpg" } PathMask { id: mask anchors.fill: parent visible: false } Component.onCompleted: { mask.beginPath() mask.moveTo(360, 200); var Pi = 3.141592653589793238463; for (var i = 1; i < 5; ++i) { mask.lineTo(200 + 160 * Math.cos(0.8 * i * Pi), 200 + 160 * Math.sin(0.8 * i * Pi)); } mask.closePath(); } OpacityMask { anchors.fill: src source: src maskSource: mask } }
  • 0 Votes
    22 Posts
    13k Views
    8Observer88
    @8Observer8 said in QOpenGLFunctions glGetString(GL_EXTENSIONS) is null: I have a same question. I try to show OpenGL version but I get empty string: I solved the problem. I activated a second video card on my laptop from code in main.cpp: #ifdef _WIN32 #include <windows.h> extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; #endif #include "Widget.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } It works too (without QString::fromLatin1): qDebug() << (const char*)glGetString(GL_VERSION);