Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there any way to apply stylesheets to QQuickWidget's QML object
Forum Updated to NodeBB v4.3 + New Features

Is there any way to apply stylesheets to QQuickWidget's QML object

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.2k Views 3 Watching
  • 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.
  • MrKozmonM Offline
    MrKozmonM Offline
    MrKozmon
    wrote on last edited by MrKozmon
    #1

    I'm trying to do this:

    QQuickWidget* widget = new QQuickWidget(this);
    widget->setSource(QUrl("qrc:/qml/1.qml"));
    widget->setStyleSheet("background:red");
    widget->show();
    

    But style sheet is not working on QML object.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The AQt-StyleSheets project is likely what you are looking for.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • MrKozmonM Offline
        MrKozmonM Offline
        MrKozmon
        wrote on last edited by
        #3

        So there is nothing about any native method, right?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What do you mean by native method ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • MrKozmonM Offline
            MrKozmonM Offline
            MrKozmon
            wrote on last edited by MrKozmon
            #5

            E.g. you can set a stylesheet to a regular Qt widget just like this:

            // For example on QPushButton
            QPushButton* myButton = new QPushButton(this);
            myButton->setStyleSheet(“color:white; background:url(“C:\my_pic.png”);”);
            

            But why i can't do the same thing on QML widgets natively. Is there a different tech behind regular Qt widgets and QML widgets. Or Has The Qt Company offer a native way to do the same thing on the QML things.

            Meanwhile thanks for your supports.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Well, there's no such thing as QML widgets. That's not the same technology at all.

              QtQuick 1 was based on the Graphics View framework but QtQuick 2 is a completely different beast and doesn't share anything with the widget world.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • V Offline
                V Offline
                Vicky Sharma
                wrote on last edited by
                #7

                But if you want to set stylesheet for button or rectangle than use
                style: ButtonStyle{
                color: "red" or etc which you want.
                }

                1 Reply Last reply
                1
                • MrKozmonM Offline
                  MrKozmonM Offline
                  MrKozmon
                  wrote on last edited by
                  #8

                  I got it, I will looking for other ways. Thanks again.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Vicky-Sharma That's rather "inline" styling of each element which is not the same as having a Qt style sheet like for the widgets module.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved