Thread
:
MAEMO 5 QT, trying a simple QT app to display battery percentage
View Single Post
krk969
2009-12-27 , 12:21
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#
17
ok the desktop widget is now ready.
but i have some issues where I might need some help again.
1. How can I add this as a desktop widget.
I followed the instructions in the development guide and wiki to create a
.desktop
file and place it in /usr/share/applications/hildon/.
This didnt work.
my .desktop file looks like this
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=batlevel
Exec=/usr/bin/run_batlevel
Icon=batlevel
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable
the only way I can run it now is using the command line or creating a shortcut to my app.
But the latter, although it puts the widget on the desktop, it opens a new app window that closes automatically after a while or when its minimized ( dont know why that happens as well )
Anyways the above two ways are just a workaround till I can figure how how to add it as a desktop widget from the menu.
2. how can I display a picture as a stylesheet for my QProgressBar ?
Ive copied a .png file in my src directory and have done the following in my code
Widget w;
w.setStyleSheet(QString("QWidget#gui {background-image:url(batlevel.png);}"));
where WIdget is a class inherited from QProgressBar.
I even tried implementing the paintEvent method as Ive read in some places that only QWidget has it implemented, for classes derived from it we need to implement.
so Ive taken an example implementation
void Widget :: paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
oh btw the Widget has been created as a window that is of type
_HILDON_WM_WINDOW_TYPE_HOME_APPLET which is what makes it a desktop applet.
Atom homeAppletAto = XInternAtom(QX11Info::display(), "_HILDON_WM_WINDOW_TYPE_HOME_APPLET", false);
Im not able to display the png file instead of the normal QProgressBar display.
any help appreciated so I can make this applet look like a battery and not some progress bar
.
cheers.
Last edited by krk969; 2009-12-27 at
12:35
.
Quote & Reply
|
krk969
View Public Profile
Send a private message to krk969
Find all posts by krk969