PDA

View Full Version : Star Rating system in QLineEdit or simliar



gig-raf
18th December 2015, 09:47
Dear Qters,

I am in the need of creating the Star Rating Widget and I was wondering how I should actually do it. I have looked at the star delegate example, which works for for QTableView and similar Widgets, but could I do something similar with a QLineEdit? Or are there better approaches?

I would very much appreciate any advice and examples on how you would program such a feature.

thanks in advance,

anda_skoa
18th December 2015, 10:33
That sounds more like a case for a custom widget, e.g. based on QWidget or QFrame.

Or you could just use the rating widget from the widget addons library: http://inqlude.org/libraries/kwidgetsaddons.html

Cheers,
_

gig-raf
23rd December 2015, 07:19
Thanks, I will take a look at the ratingWidget class. It needs to be editable so will see if it can be used.

thanks for answering!

code_err
23rd December 2015, 11:08
I think that the easiest way to do it would be using class inherited from QLabel. You will have a resource of you star bitmap and method that sets stars and prepare QPixmap created from one or more star bitmaps, then it is loaded by QLabel. It's as easy as that.

d_stranz
23rd December 2015, 15:44
It's as easy as that.

And that's pretty much what the KDE rating widget does. You can spend your time reinventing the wheel, or you can spend your time using the already-invented wheel to take you to new and interesting places.

code_err
24th December 2015, 02:46
You can spend your time reinventing the wheelAs You can see on my website, reinventing the wheel is my hobby ;P

gig-raf
5th January 2016, 11:49
Thanks Guys!

there is nothing wrong by reinventing the wheel from time to time ;-) who knows it might get rounder than before ;-)