Git Product home page Git Product logo

qtwaitingspinner's Introduction

QtWaitingSpinner

QtWaitingSpinner is a highly configurable, custom Qt widget for showing "waiting" or "loading" spinner icons in Qt applications, e.g. the spinners below are all QtWaitingSpinner widgets differing only in their configuration:

waiting spinner

Configuration

The following properties can all be controlled directly through their corresponding setters:

  • Colour of the widget
  • "Roundness" of the lines
  • Speed (rotations per second)
  • Number of lines to be drawn
  • Line length
  • Line width
  • Radius of the spinner's "dead space" or inner circle
  • The percentage fade of the "trail"
  • The minimum opacity of the "trail"

Usage

Despite being highly configurable, QtWaitingSpinner is extremely easy to use and, to make things even easier, the "QtWaitingSpinnerTest" application can assist you in determining the exact shape, size and colour you'd like your spinner to have.

For example, the embedded spinner in the QtWaitingSpinnerTest screenshot below can be created as follows:

  QtWaitingSpinner* spinner = new QtWaitingSpinner(this);

  spinner->setRoundness(70.0);
  spinner->setMinimumTrailOpacity(15.0);
  spinner->setTrailFadePercentage(70.0);
  spinner->setNumberOfLines(12);
  spinner->setLineLength(10);
  spinner->setLineWidth(5);
  spinner->setInnerRadius(10);
  spinner->setRevolutionsPerSecond(1);
  spinner->setColor(QColor(81, 4, 71));

  spinner->start(); // gets the show on the road!

test dialog

As an alternative example, the code below will create a spinner that (1) blocks all user input to the main application for as long as the spinner is active, (2) automatically centres itself on its parent widget every time "start" is called and (3) makes use of the default shape, size and colour settings.

	QtWaitingSpinner* spinner = new QtWaitingSpinner(this, Qt::ApplicationModal, true);
	spinner->start(); // starts spinning

Please use use this link for feedback, requests or issues.

Enjoy!

qt-pods

QtWaitingSpinner is available as a pod within qt-pods. See here for reference: https://github.com/cybercatalyst/qt-pods

Thanks

QtWaitingSpinner was inspired by the spin.js project.

Forks

There is also QtWaitingSpinner for Python! Thanks to z3ntu for porting it.

qtwaitingspinner's People

Contributors

kainjow avatar snowwlex avatar williamhallatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtwaitingspinner's Issues

Windows implementation

Hello!

I'm trying your spinner in an app that has been built for Mac and Windows, for Mac it works flawlessly, unfortunately for Windows it doesn't work, the spinner doesn't show up. Maybe it's an issue you have came across before?

I'm using Qt5.5 and Windows 7

Thanks in advance.

Qt6 compatibility

I'm trying the waiting spinner in my Qt6 project, and it looks like the "center on parent" isn't working when the widget is used in application modal mode:
auto waiting_spinner = new WaitingSpinnerWidget(Qt::ApplicationModal, this, true, true);

In this mode, I think the widget is being made a top-level window (presumably due to windows flags set at creation) and as a result, the calls to WaitingSpinnerWidget::updatePosition are in global screen coordinates, not relative to the parent widget, and thus the spinner appears outside of my application window!

I've fixed it for now by offsetting the coordinates using parentWidget()->mapToGlobal(), but this may be something to investigate?

QShortCut usage

I tried this project and it is very nice. But now I want to cancel (stop) the spinner if the user push the ESC button on their keyboard.

This is only possible if I set ' disableParentWhenSpinning=false'. I want to register a QShortCut if spinner is active. Do you have any idea?

I ported it to Python :)

It would be awesome if you could link my Python version for other people to find.
It uses Python 3 and PyQt5.
https://github.com/z3ntu/QtWaitingSpinner

There are still some issues with the Alpha (and maybe more?) but it runs
I FIXED IT! C++ passes by value, Python by reference and that was the problem ๐Ÿ˜„

Resizing issue

Hi,

The widget functions properly, very nice work!
I created new spinner object, set it's parent widget (a standart QWidget) and added it to a vertical layout and it's displayed nicely in my parent widget.

I have an issue when I resize the parent widget -
The waiting spinner moves to the center as needed and keeps on spinning but a "frozen" spinner remains in the position
where the moving spinner was before resizing the main widget.
As if some sort of duplication is performed.

Any insights on this matter?

Python 3.10.1 unexpected type 'float'

I am using your waitingspinnerwidget in an project, works fine. Thanks! This project run with python 3.8.10.

Now i have test my project with 3.10.1 and i got some errors

Example: TypeError: setInterval/self, int): argument 1 has unexpected type 'float'

With these fixes it works as expected.

81 painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness,
82                                    self._roundness, Qt.RelativeSize)

181 def updateTimer(self):
182       self._timer.setInterval(int(1000 / (self._numberOfLines * self._revolutionsPerSecond)))

184 def updatePosition(self):
185    if self.parentWidget() and self._centerOnParent:
186       self.move(int(self.parentWidget().width() / 2 - self.width() / 2),
187                 int(self.parentWidget().height() / 2 - self.height() / 2))

186 self.move(int(self.parentWidget().width() / 2 - self.width() / 2),
187                      int(self.parentWidget().height() / 2 - self.height() / 2))

I'm new to python and don't know if this solves all the problems now. It solved mine, I think so...

Greetings
Frank

No license?

Could you please add a license for this repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.