Results 1 to 1 of 1

Thread: ASSERT: "!"No style available without QApplication!

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Question ASSERT: "!"No style available without QApplication!

    Hello,

    I am trying to learn QML and Qt i am trying to run one example but getting the below Error
    ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1123

    My example code are below
    piechart.h
    Qt Code:
    1. #include <QtQuick/QQuickPaintedItem>
    2. #include <QColor>
    3.  
    4. class piechart : public QQuickPaintedItem
    5. {
    6. Q_OBJECT
    7. Q_PROPERTY(QString name READ name WRITE setName)
    8. Q_PROPERTY(QColor color READ color WRITE setColor)
    9. public:
    10. piechart(QQuickItem *parent = 0);
    11. void paint(QPainter *painter);
    12. };
    To copy to clipboard, switch view to plain text mode 
    piechart.cpp
    Qt Code:
    1. #include "piechart.h"
    2.  
    3. piechart::piechart(QQuickItem *parent)
    4. : QQuickPaintedItem(parent)
    5. {
    6.  
    7. }
    8.  
    9. void piechart::paint(QPainter *painter)
    10. {
    11. QPen pen(m_color, 2);
    12. painter->setPen(pen);
    13. painter->setRenderHints(QPainter::Antialiasing, true);
    14. painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
    15. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QGuiApplication>
    2. #include <QQmlApplicationEngine>
    3. #include <QtQuick/QQuickView>
    4. #include "piechart.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QGuiApplication app(argc, argv);
    9.  
    10. QQmlApplicationEngine engine;
    11. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    main.qml
    Qt Code:
    1. import QtQuick 2.5
    2. import QtQuick.Window 2.2
    3. import QtCharts 2.0
    4.  
    5. Item {
    6. anchors.fill: parent
    7. property variant othersSlice: 0
    8.  
    9. ChartView {
    10. id: chart
    11. title: "Top-5 car brand shares in Finland"
    12. anchors.fill: parent
    13. legend.alignment: Qt.AlignBottom
    14. antialiasing: true
    15.  
    16. PieSeries {
    17. id: pieSeries
    18. PieSlice { label: "Volkswagen"; value: 13.5 }
    19. PieSlice { label: "Toyota"; value: 10.9 }
    20. PieSlice { label: "Ford"; value: 8.6 }
    21. PieSlice { label: "Skoda"; value: 8.2 }
    22. PieSlice { label: "Volvo"; value: 6.8 }
    23. }
    24. }
    25.  
    26. Component.onCompleted: {
    27. // You can also manipulate slices dynamically
    28. othersSlice = pieSeries.append("Others", 52.0);
    29. pieSeries.find("Volkswagen").exploded = true;
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 
    qmlApp.pro
    TEMPLATE = app

    QT += core gui
    QT += qml quick
    CONFIG += c++11

    SOURCES += main.cpp \
    piechart.cpp

    RESOURCES += qml.qrc

    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =

    # Default rules for deployment.
    include(deployment.pri)

    HEADERS += \
    piechart.h
    Can anyone let me know why i am getting the Assert Error.
    Last edited by anh5kor; 27th July 2017 at 14:02. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 12th April 2017, 12:03
  2. Replies: 2
    Last Post: 2nd March 2015, 16:27
  3. Replies: 0
    Last Post: 9th January 2015, 11:09
  4. ASSERT: "bitmap" in file image\qnativeimage.cpp, line 114
    By DusanDusan in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2012, 07:30
  5. Replies: 1
    Last Post: 5th February 2011, 22:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.