Reply
Thread Tools
Posts: 108 | Thanked: 329 times | Joined on Apr 2010 @ Bosnia and Herzegovina
#1
My question is simple (don't know about the answer) - how do I make list items look like this in Qt for Maemo 5?




To be more specific, I want that "special" second row with different color and smaller font. I also need the icons (like in SeriesFinale), so I've created QListWidgetItems with text and icons, added them to a QListWidget and it works great. But I don't have any idea how to add that special text underneath. If I put a newline in item text, it really shows it in the next line, but predictably, with same color and size. I'm still new to Qt, so I don't know where to look. I found this, which is kinda like what I want to do, only with buttons. I also read about writing a "delegate", which, if I understood it right, is like writing custom controls/widgets. But this kind of list seems standard for Maemo 5, so I wanted to ask if there is a standard/easy way to do this. Any ideas?

Last edited by TheBurek; 2010-10-22 at 15:03.
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#2
i would guess...... CSS - style sheets work, there are quite a few limitations but, they work.

Dependend on css - but here's some links.

http://doc.trolltech.com/4.7/stylesheet.html

http://doc.qt.nokia.com/4.6/stylesheet-syntax.html

(Healthcheck uses css in PyQT - but i'm currently working on a c++ version so will probably use it again.)
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
Khertan's Avatar
Posts: 1,012 | Thanked: 817 times | Joined on Jul 2007 @ France
#3
If you want something fully custom which i suggest instead of using stylesheet that are broken on some QWidget on Maemo due to the Maemo style :

QStyledItemDelegate

Take a look at Khweeteur source code for example on how i use it : http://gitorious.org/khweeteur/khwee...ur/__init__.py
 

The Following 2 Users Say Thank You to Khertan For This Useful Post:
Posts: 108 | Thanked: 329 times | Joined on Apr 2010 @ Bosnia and Herzegovina
#4
Those look promising. Isn't as easy as I was hoping for, but at least now I know which way to proceed. Thank you both. I'll report my findings when I figure this out, in case someone else stumbles upon this problem.
 

The Following User Says Thank You to TheBurek For This Useful Post:
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#5
The Hildon Style Guide has a list of the logical font and colour names that you provide as arguments to the static methods of the QMaemo5Style class. The blue text in your screenshot is obtained using the logical colour name 'ActiveTextColor'. So, you could set the text colour of a QListWidgetItem as follows:

Code:
listWidgetItem.setTextColor(QMaemo5Style.standardColor("ActiveTextColor"))
Unfortunately, I have not been able to get this to work in PyQt. I suspect the class QMaemo5Style is not available in PyQt.

To obtain multiple lines of text with different fonts, you can create a custom widget containing the required number of QLabels etc in a grid layout, and set the QListWidgetItem's widget to the custom widget that you have created, using the setItemWidget() method of the QListWidget class.

As an example, I am currently developing a YouTube client for the N900, and I created a custom widget containing:
  • A QLabel with a QFrame containing a QPixmap showing the video thumbnail.
  • A QLabel containing the video duration.
  • A QLabel containing the video title.
  • A QLabel containing the username of the uploader (font size 18px).
  • A QLabel containing an QPixmap showing the rating.

The label are set in a grid layout. You can do all of this in Qt Designer if you wish.

Screenshot:


Last edited by marxian; 2010-10-22 at 22:01.
 

The Following User Says Thank You to marxian For This Useful Post:
Posts: 108 | Thanked: 329 times | Joined on Apr 2010 @ Bosnia and Herzegovina
#6
Yeah, that's the color, I tried it just now. But my problem is how to add that "Active text" to my ItemWidget. I read about style sheets, delegates, MVC in Qt, tried to make some of those, segfaulted a few times, and gave up for today. I see you're all using Python... that's lovely. I'm trying to do this in C++ and that can be such a burden...

EDIT : Oh, I didn't see all that extra info in time. Will try that, thanks.

Last edited by TheBurek; 2010-10-22 at 22:06.
 
Posts: 108 | Thanked: 329 times | Joined on Apr 2010 @ Bosnia and Herzegovina
#7
Oh, that worked really great. I've also put more stuff in my item, because now I can. Thank you very much, this solved my problem - and then some.
 
Reply


 
Forum Jump


All times are GMT. The time now is 05:31.