Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. QML -AnfängerFrage
Forum Updated to NodeBB v4.3 + New Features

QML -AnfängerFrage

Scheduled Pinned Locked Moved Unsolved German
3 Posts 2 Posters 500 Views
  • 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.
  • S Offline
    S Offline
    sowas
    wrote on last edited by sowas
    #1

    Muss das Wurzelelement immer Window sein damit die Anwendung angezeigt wird?
    z.B wenn man das Qt Beispiel nimmt dann sieht man nichts.

    import QtQuick 2.0

    Rectangle{
    width: 100
    height: 100
    color: "red"
    border.color: "black"
    boder.width: 5
    radius: 10
    }
    Erst wenn ich es als Kind von Windows mache dann wird das rote Rechteck angezeigt. Übersehe ich hier was?
    Danke

    J.HilkJ 1 Reply Last reply
    0
    • S sowas

      Muss das Wurzelelement immer Window sein damit die Anwendung angezeigt wird?
      z.B wenn man das Qt Beispiel nimmt dann sieht man nichts.

      import QtQuick 2.0

      Rectangle{
      width: 100
      height: 100
      color: "red"
      border.color: "black"
      boder.width: 5
      radius: 10
      }
      Erst wenn ich es als Kind von Windows mache dann wird das rote Rechteck angezeigt. Übersehe ich hier was?
      Danke

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @sowas kommt drauf an, in was dein QML File geladen wird.

      • ein QQuickWidget sollte mit deinem Beispiel problemlos klar kommen.
      • als root Element einer QQmlApplicationEngine... nein. Das muss ein Window oder ein derivative wie ApplicationWindow sein, was als root Element geladen wird.

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sowas
        wrote on last edited by
        #3

        @J-Hilk said in QML -AnfängerFrage:

        QQuickWidget

        Danke für die schelle Antwort.
        Ich hatte kein QQuickWidget, ich habe eine neue QMl-Anwendung angemeldet und den Standarttext

        Window {
            width: 640
            height: 480
            visible: true
            title: qsTr("Hello World")
        }
        

        durch

        Rectangle{
            width: 100
            height: 100
            color: "red"
            border.color: "black"
            boder.width: 5
            radius: 10
            visible: true
        }
        

        ersetzt, aber in der main.cpp war die QQmlApplicationEngine:

        int main(int argc, char *argv[])
        {
            QGuiApplication app(argc, argv);
        
            QQmlApplicationEngine engine;
            const QUrl url(u"qrc:/viereck/main.qml"_qs);
            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();
        }
        
        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