Results 1 to 5 of 5

Thread: QSystemTrayIcon Problem

  1. #1
    Join Date
    Jul 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default QSystemTrayIcon Problem

    Hi friends,


    when i use QSystemTrayIcon example on Simulator, it's work. but if i compile for Symbain Device on Symbian Build section, i give error : 'QSystemTrayIcon' was not declared in this scope. But i was declared on mainwindow.h and also mainwindow.cpp -> #include "qsystemtrayicon.h"
    i am using QT Creator 4.7.4. And i building for Symbian Belle

    What should i do ?
    (sorry for bad English)

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: QSystemTrayIcon Problem

    1) mainwondow.h and mainwindow.cpp not in this example http://www.trinitydesktop.org/docs/q...p-systray.html
    2) Qt include should look like #include <QSystemTrayIcon> not #include "QSystemTrayIcon.h"
    3) show your code.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. The following user says thank you to amleto for this useful post:

    SNZ (2nd July 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default Re: QSystemTrayIcon Problem

    I can't understand what mean "mainwondow.h and mainwindow.cpp not in this example". i have only 1 header and 2 sources. Header is MainWindow.h
    sources are mainwindow.cpp and main.cpp. i am creating a Mobile Qt Application.

    My Code is:

    QSystemTrayIcon *tray =new QSystemTrayIcon;
    tray->setIcon(QIcon("emailRead.png"));
    tray->show();

    i included #include <QSystemTrayIcon> in Mainwindow.h also mainwindow.cpp. This code is working on simulator. But when i compile with symbian device give error "error: expected type-specifier before 'QSystemTrayIcon'" blinking on my code.

    Thanx For Reply

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: QSystemTrayIcon Problem

    you said:
    when i use QSystemTrayIcon example on Simulator"

    What example? Since you are making everyone guess what you are talking about by
    1) NOT showing any code
    2) NOT giving any links to the code you are talking about
    I made best effort guess that you were talking about the first example I found by googling.

    Does symbian even have a tray/icon?

    read my sig - give COMPLETE compilable code!
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. #5
    Join Date
    Jul 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default Re: QSystemTrayIcon Problem

    I am using QT Creator 4.7.4, QtSDK 1.2, i am creating an application for N8 with Symbian Belle SDK. I have an icon in my resources named "emailRead.png". My Code Template;


    MainWindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. #include <QtCore/QCoreApplication>
    5. #include <QSystemTrayIcon>
    6. MainWindow::MainWindow(QWidget *parent)
    7. : QMainWindow(parent), ui(new Ui::MainWindow)
    8. {
    9. ui->setupUi(this);
    10. QSystemTrayIcon *tray = new QSystemTrayIcon(this);
    11. tray->setIcon(QPixmap(":/emailRead.png"));
    12. tray->show();
    13.  
    14. }
    15.  
    16. MainWindow::~MainWindow()
    17. {
    18. delete ui;
    19. }
    20.  
    21. void MainWindow::setOrientation(ScreenOrientation orientation)
    22. {
    23. #if defined(Q_OS_SYMBIAN)
    24. // If the version of Qt on the device is < 4.7.2, that attribute won't work
    25. if (orientation != ScreenOrientationAuto) {
    26. const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
    27. if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
    28. qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
    29. return;
    30. }
    31. }
    32. #endif // Q_OS_SYMBIAN
    33.  
    34. Qt::WidgetAttribute attribute;
    35. switch (orientation) {
    36. #if QT_VERSION < 0x040702
    37. // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    38. case ScreenOrientationLockPortrait:
    39. attribute = static_cast<Qt::WidgetAttribute>(128);
    40. break;
    41. case ScreenOrientationLockLandscape:
    42. attribute = static_cast<Qt::WidgetAttribute>(129);
    43. break;
    44. default:
    45. case ScreenOrientationAuto:
    46. attribute = static_cast<Qt::WidgetAttribute>(130);
    47. break;
    48. #else // QT_VERSION < 0x040702
    49. case ScreenOrientationLockPortrait:
    50. attribute = Qt::WA_LockPortraitOrientation;
    51. break;
    52. case ScreenOrientationLockLandscape:
    53. attribute = Qt::WA_LockLandscapeOrientation;
    54. break;
    55. default:
    56. case ScreenOrientationAuto:
    57. attribute = Qt::WA_AutoOrientation;
    58. break;
    59. #endif // QT_VERSION < 0x040702
    60. };
    61. setAttribute(attribute, true);
    62. }
    63.  
    64. void MainWindow::showExpanded()
    65. {
    66. #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    67. showMaximized();
    68. #elif defined(Q_WS_MAEMO_5)
    69. showMaximized();
    70. #else
    71. show();
    72. #endif
    73. }
    To copy to clipboard, switch view to plain text mode 



    mainwindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3. #include <QSystemTrayIcon>
    4. #include <QtGui/QMainWindow>
    5.  
    6. namespace Ui {
    7. class MainWindow;
    8. }
    9.  
    10. class MainWindow : public QMainWindow
    11. {
    12. Q_OBJECT
    13. public:
    14. enum ScreenOrientation {
    15. ScreenOrientationLockPortrait,
    16. ScreenOrientationLockLandscape,
    17. ScreenOrientationAuto
    18. };
    19.  
    20. explicit MainWindow(QWidget *parent = 0);
    21. virtual ~MainWindow();
    22.  
    23. // Note that this will only have an effect on Symbian and Fremantle.
    24. void setOrientation(ScreenOrientation orientation);
    25.  
    26. void showExpanded();
    27.  
    28. private:
    29. Ui::MainWindow *ui;
    30. };
    31.  
    32. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 




    main.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. #include <QtGui/QApplication>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. MainWindow mainWindow;
    10. mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
    11. mainWindow.showExpanded();
    12.  
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 




    .pro


    Qt Code:
    1. # Add files and directories to ship with the application
    2. # by adapting the examples below.
    3. # file1.source = myfile
    4. # dir1.source = mydir
    5. DEPLOYMENTFOLDERS = # file1 dir1
    6.  
    7. symbian:TARGET.UID3 = 0xE0D24294
    8.  
    9. # Smart Installer package's UID
    10. # This UID is from the protected range
    11. # and therefore the package will fail to install if self-signed
    12. # By default qmake uses the unprotected range value if unprotected UID is defined for the application
    13. # and 0x2002CCCF value if protected UID is given to the application
    14. #symbian:DEPLOYMENT.installer_header = 0x2002CCCF
    15.  
    16. # Allow network access on Symbian
    17. #symbian:TARGET.CAPABILITY += NetworkServices
    18.  
    19. # If your application uses the Qt Mobility libraries, uncomment
    20. # the following lines and add the respective components to the
    21. # MOBILITY variable.
    22. # CONFIG += mobility
    23. # MOBILITY +=
    24.  
    25. SOURCES += main.cpp mainwindow.cpp
    26. HEADERS += mainwindow.h
    27. FORMS += mainwindow.ui
    28.  
    29. # Please do not modify the following two lines. Required for deployment.
    30. include(deployment.pri)
    31. qtcAddDeployment()
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QSystemTrayIcon Set Text
    By sagirahmed in forum Qt Programming
    Replies: 0
    Last Post: 30th September 2011, 10:40
  2. QSystemTrayIcon problem in windows
    By buf1024 in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2010, 06:18
  3. QSystemTrayIcon help
    By SkylineBob in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2010, 18:22
  4. Problem with QSystemTrayIcon on Mac OS
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2008, 11:53
  5. problem when using QSystemTrayIcon
    By thrantir in forum Qt Programming
    Replies: 5
    Last Post: 23rd July 2007, 11:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.