Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2007
Re: QSystemTray Icon


Message 1 in thread

Hi

2007/10/31, Dimitri <dimitri@xxxxxxxxxxxxx>:
>
> I wrote:
> > I wrote:
> >> If you haven't yet reported the bug to Trolltech, please report it
> here:
> >>     http://trolltech.com/bugreport-form
> >
> > By the way, before deciding it's a Qt bug, do you have a minimal example
> > that reproduces the problem?
>
> Are you calling setIcon() repeatedly, 2-3 times per second? There's no
> function QSystemTrayIcon::setPixmap().



Yes, i create a Pixmap, and then i create an Icon, and then call setIcon().
I call it 2/3 times per second, but also slowing down the speed does not
solve.
That is, the flickering happens more rarely.

In my opinion the problem is that there is no painter available on the
systray icon,
and the workaround i apply is a bit tricky.

I am using QT4.3 on X11 (debian GNU/Linux/Xorg )




On which system do you see the problem? Which version of Qt is this?
>
> I don't see the problem on Linux with Qt 4.3.2. To be honest, I have not
> tried
> calling setIcon() programmatically, but I did run the
> examples/desktop/systray
> example. Clicking on the icon changes the current icon. I don't see any
> visible flickering. Maybe it would be more visible with different icons?
>
> --
> Dimitri
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ] 

Message 2 in thread

Hi,

> Yes, i create a Pixmap, and then i create an Icon, and then call setIcon().
> I call it 2/3 times per second, but also slowing down the speed does not 
> solve.
> That is, the flickering happens more rarely.
> 
> In my opinion the problem is that there is no painter available on the 
> systray icon,
> and the workaround i apply is a bit tricky.

That shouldn't be a problem, QSystemTray should do the right thing for you.

I cannot reproduce the problem here using examples/desktop/systray. Can you?

> I am using QT4.3 on X11 (debian GNU/Linux/Xorg )

I am using Qt/X11 4.3.2 on Fedora 7 + Nvidia graphics drivers.

--
 [ signature omitted ] 

Message 3 in thread

Yes, i attach a program that Girish on the mailing list sent me some time
ago.
It behaves the same way my program does.

Maybe your machine is more powerful than mine, anyway i verified the same
behaviour on a

1.50 GHz cpu, 1GB ram
1.8 GHz cpu, 512MB ram
 3.0 laptop, 512MB ram

Although they are not very up to date machines, i think they should be
enough to do the work without noticing that the icon disappears and
reappears
continuously.

I would insist on my opinion: to be able to draw on the QSystemTray we would
need a painter on that, just like any other widget we want to paint on.

Thank you!

Giacomo


2007/11/5, Dimitri <dimitri@xxxxxxxxxxxxx>:
>
> Hi,
>
> > Yes, i create a Pixmap, and then i create an Icon, and then call
> setIcon().
> > I call it 2/3 times per second, but also slowing down the speed does not
> > solve.
> > That is, the flickering happens more rarely.
> >
> > In my opinion the problem is that there is no painter available on the
> > systray icon,
> > and the workaround i apply is a bit tricky.
>
> That shouldn't be a problem, QSystemTray should do the right thing for
> you.
>
> I cannot reproduce the problem here using examples/desktop/systray. Can
> you?
>
> > I am using QT4.3 on X11 (debian GNU/Linux/Xorg )
>
> I am using Qt/X11 4.3.2 on Fedora 7 + Nvidia graphics drivers.
>
> --
> Dimitri
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ] 

Attachment: systray.tar.gz
Description: GNU Zip compressed data


Message 4 in thread

Hi,

> Yes, i attach a program that Girish on the mailing list sent me some 
> time ago.

Have you communicated with Girish on this mailing list, or after having sent a 
bug report? What did he tell you concerning this test program? I still don't 
know whether you have sent a bug report or not.

> It behaves the same way my program does.
> 
> Maybe your machine is more powerful than mine, anyway i verified the 
> same behaviour on a
> 
> 1.50 GHz cpu, 1GB ram
> 1.8 GHz cpu, 512MB ram
>  3.0 laptop, 512MB ram

I have a workstation with a 2.80 GHz Pentium processor. Not much of a 
difference. I really can't reproduce any flickering.

> Although they are not very up to date machines, i think they should be
> enough to do the work without noticing that the icon disappears and 
> reappears
> continuously.

Sure.

> I would insist on my opinion: to be able to draw on the QSystemTray we would
> need a painter on that, just like any other widget we want to paint on.

My guess is that painting directly with a painter is not portable. I'm pretty 
sure it's not the responsibility of the application to directly draw into the 
tray on most systems. That's just a guess though :-) Anyway, what's wrong with 
just setting the icon (as long as there is no flickering)? It looks like what 
you really need is fixing the flickering. How this is fixed should not be 
important in your context, should it?

--
 [ signature omitted ] 

Message 5 in thread

2007/11/6, Dimitri <dimitri@xxxxxxxxxxxxx>:
>
> Hi,
>
> > Yes, i attach a program that Girish on the mailing list sent me some
> > time ago.
>
> Have you communicated with Girish on this mailing list, or after having
> sent a
> bug report? What did he tell you concerning this test program? I still
> don't
> know whether you have sent a bug report or not.


Yes he says he does not experience any flickering.
He talked about Qt on Windows.
Anyway, he tested with the same test program i attached in your last email


> It behaves the same way my program does.
> >
> > Maybe your machine is more powerful than mine, anyway i verified the
> > same behaviour on a
> >
> > 1.50 GHz cpu, 1GB ram
> > 1.8 GHz cpu, 512MB ram
> >  3.0 laptop, 512MB ram
>
> I have a workstation with a 2.80 GHz Pentium processor. Not much of a
> difference. I really can't reproduce any flickering.
>
> > Although they are not very up to date machines, i think they should be
> > enough to do the work without noticing that the icon disappears and
> > reappears
> > continuously.
>
> Sure.
>
> > I would insist on my opinion: to be able to draw on the QSystemTray we
> would
> > need a painter on that, just like any other widget we want to paint on.
>
> My guess is that painting directly with a painter is not portable. I'm
> pretty
> sure it's not the responsibility of the application to directly draw into
> the
> tray on most systems. That's just a guess though :-) Anyway, what's wrong
> with
> just setting the icon (as long as there is no flickering)?



There is nothing wrong but in  my opinion it is tricky:

1. Create a QPixmap
2. draw on it
3. create a QIcon from the pixmap
4. Set the new icon on the system tray

instead of

- just painting on the same system tray.


It looks like what
> you really need is fixing the flickering. How this is fixed should not be
> important in your context, should it?


Yes, of course. If doing all that becomes efficient to me it is enough :)

Thanks again.

Do you think it is the case to send a bug report?




--
 [ signature omitted ] 

Message 6 in thread

Giacomo wrote:
> 
> 
> 2007/11/6, Dimitri <dimitri@xxxxxxxxxxxxx <mailto:dimitri@xxxxxxxxxxxxx>>:
> 
>     Hi,
> 
>      > Yes, i attach a program that Girish on the mailing list sent me some
>      > time ago.
> 
>     Have you communicated with Girish on this mailing list, or after
>     having sent a
>     bug report? What did he tell you concerning this test program? I
>     still don't
>     know whether you have sent a bug report or not.
> 
> 
> Yes he says he does not experience any flickering.
> He talked about Qt on Windows.
> Anyway, he tested with the same test program i attached in your last email
>  
> 

Ok, I have managed to reproduce the problem on my laptop (linux) with 
Dimitri's example. I now know the reason for the flicker. the fix is 
going to be tricky. For some strange reason, it doesn't flicker on my 
linux computer at office.

I am working on it.

Girish

--
 [ signature omitted ] 

Message 7 in thread

Hi,

> Yes, i attach a program that Girish on the mailing list sent me some 
> time ago.
> It behaves the same way my program does.

OK, I can reproduce that. Attached is a minimal example.

The strange thing is that I don't see any flickering for some time, then the 
icon starts flickering for a few seconds, then it stops, then it starts again...

Have you sent a bug report to Trolltech yet ?

--
 [ signature omitted ] 
#include <QtGui>

class MyObject : public QObject {
    Q_OBJECT
public:
    MyObject();
protected:
    void timerEvent(QTimerEvent *event);
private:
    QImage image;
    QSystemTrayIcon *trayIcon;
};

MyObject::MyObject() : QObject(0), image(32, 32, QImage::Format_RGB32) {
    if (!QSystemTrayIcon::isSystemTrayAvailable()) {
        qDebug() << "System Tray not available";
    }
    image.fill(0x00bbbbbbbb);
    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setIcon(QPixmap::fromImage(image));
    trayIcon->show();
    startTimer(100);
}

void MyObject::timerEvent(QTimerEvent *event) {
    static int frame = 0;
    QImage i = image;
    QRect r(0, 0, frame%i.width(), frame%i.height());
    r.moveCenter((QPoint(i.width()/2, i.height()/2)));
    QPainter painter(&i);
    painter.fillRect(r, Qt::red);
    trayIcon->setIcon(QPixmap::fromImage(i));
    ++frame;
}

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MyObject w;
    return app.exec();
}