kleine frage zum "KSystemTray"



  • also ich habe jetzt diese wunderbare klasse gefunden:

    KSystemTray ( QWidget* parent = 0, const char* name = 0 )
    

    und dieses beispiel

    class Outpost : public QWidget
     {
     Q_OBJECT
     public:
     Outpost(QWidget* parent = 0, const char * name = 0);
     ~Outpost();
     protected:
     KSystemTray* trayicon;
     };
    
     Outpost::Outpost(QWidget* parent, const char * name) : QWidget(parent, name)
     {
     trayicon = new KSystemTray(this, "kashmere outpost");
     trayicon->show();
     }
     Outpost::~Outpost()
     {
    
     }
    
     #include "outpost.moc.cpp"
    
     int main(int argc, char **argv)
     {
     KCmdLineArgs::init( argc, argv, "outpost", "test app", "0.1" );
     KApplication app(argc, argv);
     Outpost outpost;
     app.setMainWidget(&outpost);
     outpost.show();
     return app.exec();
     }
    

    was ich damit umgesetzt habe

    KSystemTray* trayicon;
      trayicon = new KSystemTray(this, "kashmere outpost");
      trayicon->show();
    

    ich weiß leider 😞 nicht was eigenttlich

    trayicon = new KSystemTray(this, "kashmere outpost");
    

    macht bzw ein "this" ist und was es mit

    KSystemTray ( QWidget* parent = 0, const char* name = 0)
    

    zu tun hat???

    und das andere problem ist, das ich noch ein icon brauche, mein platz ist praktisch durchsichtig... .
    und ffalls es jemand wissen sollte, wie bekommt mans hin das nur ein icon geöffnet wird????
    danke, mfg hanse! :p



  • Vielleicht solltest du zuerst die C++ Grundlagen wiederholen.

    trayicon = new KSystemTray(this, "kashmere outpost");
    

    this is ein Pointer auf das aktuelle Objekt. Da der Konstruktor von KSystemTray hier einen parent erwartet, wird die aktuelle Klasse zum Parent des KSystemTray s

    Wenn du dir weiterhin die Dokumentation zum KSystemTray anschaust, dann siehst du, dass die Klasse die Methode setPixmap() zum setzen des Icons hat.



  • tut mir leid, trotzdem danke.



  • ich versteh das nicht so recht??? wie müsste das richtig aussehen?

    Fehler: keine passende Funktion für Aufruf von »KSystemTray::setPixmap(QPixmap*&)«
    /usr/lib/qt-3.3/include/qlabel.h:104: Anmerkung: Kandidaten sind: virtual void QLabel::setPixmap(const QPixmap&)
    make: *** [.obj/form1.o] Fehler 1

    void Form1::show_Tray() 
    {
      KSystemTray* trayicon;
      trayicon = new KSystemTray(this, "kashmere outpost");
      QPixmap *pixmap = new QPixmap("kpf.png");
      trayicon->setPixmap(pixmap );
      trayicon->show();
    }
    


  • hanse schrieb:

    ich versteh das nicht so recht??? wie müsste das richtig aussehen?

    Fehler: keine passende Funktion für Aufruf von »KSystemTray::setPixmap(QPixmap*&)«
    /usr/lib/qt-3.3/include/qlabel.h:104: Anmerkung: Kandidaten sind: virtual void QLabel::setPixmap(const QPixmap&)
    make: *** [.obj/form1.o] Fehler 1

    void Form1::show_Tray() 
    {
      KSystemTray* trayicon;
      trayicon = new KSystemTray(this, "kashmere outpost");
      QPixmap *pixmap = new QPixmap("kpf.png");
      trayicon->setPixmap(pixmap );
      trayicon->show();
    }
    

    Die Funktion verlangt eine Referenz auf ein Objekt, keinen Pointer darauf.
    Mach es am Besten so:

    QPixmap pixmap("kpf.png");
    trayicon->setPixmap(pixmap);
    

    oder kürzer:

    trayicon->setPixmap(QPixmap("kpf.png"));
    

Anmelden zum Antworten