Change color to BusyIndicator
-
wrote on 31 Aug 2018, 14:56 last edited by
Hi,
I search on the net but I didn't find something usefull for this.
I have a simple BusyIndicator that I show in my c++ application, I just want to change the color from black (default) to blue. How can I do this?
this is my code:
BusyIndicator.qmlimport QtQuick 2.6 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Controls.Styles 1.4 Rectangle { width: 50 height: 50 visible: true BusyIndicator { id: busyIndication anchors.centerIn: parent // 'running' defaults to 'true' } }
Thanks in advance for your help!
-
Hi,
I search on the net but I didn't find something usefull for this.
I have a simple BusyIndicator that I show in my c++ application, I just want to change the color from black (default) to blue. How can I do this?
this is my code:
BusyIndicator.qmlimport QtQuick 2.6 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Controls.Styles 1.4 Rectangle { width: 50 height: 50 visible: true BusyIndicator { id: busyIndication anchors.centerIn: parent // 'running' defaults to 'true' } }
Thanks in advance for your help!
-
wrote on 3 Sept 2018, 08:31 last edited by
Hi and thanks for the answer.
I've already tried that solution, but it gives me this error:qrc:/rec/BusyProva.qml:18:9: Type BusyIndicator unavailable qrc://busyindicator.qml: No such file or directory
My qml file is called BusyProva.qml so I don't know what it's trying to do with the second error.
this is the complete code:
QQuickView *rotella = new QQuickView(); rotella->setResizeMode(QQuickView::SizeRootObjectToView); QWidget *container = QWidget::createWindowContainer(rotella, this); container->setFocusPolicy(Qt::TabFocus); rotella->setSource(QUrl("qrc:/rec/BusyProva.qml")); container->setGeometry(this->width()/2 - 25, this->height()/2 - 25, 50, 50); rotella->show();
BusyProva.qml
import QtQuick 2.6 import QtQuick.Controls 2.1 Rectangle { BusyIndicator { id: control contentItem: Item { implicitWidth: 64 implicitHeight: 64 Item { id: item x: parent.width / 2 - 32 y: parent.height / 2 - 32 width: 64 height: 64 opacity: control.running ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: 250 } } RotationAnimator { target: item running: control.visible && control.running from: 0 to: 360 loops: Animation.Infinite duration: 1250 } Repeater { id: repeater model: 6 Rectangle { x: item.width / 2 - width / 2 y: item.height / 2 - height / 2 implicitWidth: 10 implicitHeight: 10 radius: 5 color: "#21be2b" transform: [ Translate { y: -Math.min(item.width, item.height) * 0.5 + 5 }, Rotation { angle: index / repeater.count * 360 origin.x: 5 origin.y: 5 } ] } } } } } }
Can you help me on this?
-
wrote on 3 Sept 2018, 08:51 last edited by
After some other tests it looks like this problem is only given when the QtQuickControls is 2.0 or more.
For QtQuickControls 1.4 it does not give any problem but I have to use a different code:import QtQuick 2.6 import QtQuick.Controls 1.4 Rectangle { width: 50 height: 50 visible: true BusyIndicator { id: busyIndication anchors.centerIn: parent // 'running' defaults to 'true' } }
Because the property contentItem is not found using QtQuick.Controls 1.4
But the porblem of this code is that I can't change the color of the busyIndicator. -
wrote on 10 May 2019, 16:42 last edited by
This post is pretty old. However, there is another way, easier, to change the color of the BusyIndicator. If you combine a Busy Indicator with ColorOverlay, you will have the desired result.
Good luck.
-
wrote on 20 Jun 2019, 08:50 last edited by haftado3
i have an easier and better solution for this :
import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Controls.Universal 2.12 BusyIndicator { id: busyIndicator //x: 290 //y: 330 implicitWidth: 75 implicitHeight: 75 visible: running running: true anchors.horizontalCenter: parent.horizontalCenter Universal.accent: Universal.Orange //here you can set color }
-
i have an easier and better solution for this :
import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Controls.Universal 2.12 BusyIndicator { id: busyIndicator //x: 290 //y: 330 implicitWidth: 75 implicitHeight: 75 visible: running running: true anchors.horizontalCenter: parent.horizontalCenter Universal.accent: Universal.Orange //here you can set color }
-
@haftado3 Hi. That solution is easier, but with limited colors. What about the black, for example?
wrote on 21 Jun 2019, 13:56 last edited by Gojir4@oria66
Universal.Orange
is just predefined color but you can use any color. But I guess it will no longer work if you change style to Material for example.From Qt Doc: Note: Even though the accent can be any color, it is recommended to use one of the pre-defined Universal colors that have been designed to work well with the rest of the Universal style palette.
-
@oria66
Universal.Orange
is just predefined color but you can use any color. But I guess it will no longer work if you change style to Material for example.From Qt Doc: Note: Even though the accent can be any color, it is recommended to use one of the pre-defined Universal colors that have been designed to work well with the rest of the Universal style palette.
wrote on 21 Jun 2019, 14:03 last edited by@Gojir4. Thanks for the anotation!
-
@haftado3 Hi. That solution is easier, but with limited colors. What about the black, for example?
-
wrote on 6 Nov 2020, 14:54 last edited by
Hi.
With fullscreen EGLFS applications without a desktop environment theUniversal
themes don't seem to work.What works to change the color of the
BusyIndicator
though is to change itspalette.dark
property to the color you want.BusyIndicator { ... palette.dark: "blue" ... }
-
wrote on 27 Jan 2021, 12:50 last edited by
Hi,
I know I'm opening an old question but it is not working for me:
BusyIndicator {
x: stageRec.width/2 -width + 30
y: 300
running: backend.checkupReadyState?false : true
Universal.accent: Universal.Orange
}
this is my code and my color isn't changing. anyone know why? -
Hi,
I know I'm opening an old question but it is not working for me:
BusyIndicator {
x: stageRec.width/2 -width + 30
y: 300
running: backend.checkupReadyState?false : true
Universal.accent: Universal.Orange
}
this is my code and my color isn't changing. anyone know why?@Talya HI and welcome,
take look at the documentation, the section about customizing the busy indicator:
https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-busyindicator
-
wrote on 27 Jan 2021, 13:14 last edited by
Thank you very!