Results 1 to 13 of 13

Thread: Icons dont apear in tolbar

  1. #1
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Cool Icons dont apear in tolbar

    Hi. I'm a newby migration to Qt 4 from MS Visual C++ 6.
    I create a basic Window in Designer, with menu and toolbar with actions and icons, but the icons dont show. I create the qrc file and use Q_INIT_RESOURCE.

    What could be wrong?

    HELP!!!!!

    my code is:

    Qt Code:
    1. #include <QApplication>
    2. #include <QMainWindow>
    3. #include "ui_janela.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7.  
    8. Q_INIT_RESOURCE(images);
    9. QApplication app(argc, argv);
    10.  
    11. Ui_mainWindow ui;
    12.  
    13.  
    14. ui.setupUi(ja);
    15.  
    16. ja->show();
    17.  
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 19th August 2008 at 19:55. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Icons dont apear in tolbar

    did you add resource declaration to .pro file?
    Qt Code:
    1. RESOURCES += resource_file_name.qrc
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Icons dont apear in tolbar

    yes i did

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Icons dont apear in tolbar

    What is your icons format?

  5. #5
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Icons dont apear in tolbar

    they are .png. Ive copied the images from the tutorials of the oficial qt 4 porgramming book

    I've also tried the example of the MDI, without the designer, i've added a new icon to the toolbar, new action, new code to that specific tolbar botton and worked with .png and .ico, but with the designer it doesnt work

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Icons dont apear in tolbar

    can you show your pro-file?

  7. #7
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Icons dont apear in tolbar

    ################################################## ####################
    # Automatically generated by qmake (2.01a) dom 17. Ago 22:33:02 2008
    ################################################## ####################

    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    # Input
    FORMS += janela.ui
    SOURCES += janela.cpp
    RESOURCES += images.qrc

  8. #8
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Icons dont apear in tolbar

    the image.qrc files is:

    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource>
    3. <file>images/copy.png</file>
    4. <file>images/cut.png</file>
    5. <file>images/new.png</file>
    6. <file>images/open.png</file>
    7. <file>images/paste.png</file>
    8. <file>images/save.png</file>
    9.  
    10. </qresource>
    11. </RCC>
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 19th August 2008 at 19:57. Reason: missing [code] tags

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Icons dont apear in tolbar

    I think problem in ui file.
    did ui file contain lines like these
    Qt Code:
    1. ....
    2. <iconset resource="test.qrc" >
    3. ...
    4. <resources>
    5. <include location="test.qrc" />
    6. </resources>
    7. ...
    To copy to clipboard, switch view to plain text mode 
    ?

  10. #10
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Icons dont apear in tolbar

    If the problem is with this file i think thats not editable because its create by the designer
    am i right ? But where it goes:
    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading ui file 'janela.ui'
    3. **
    4. ** Created: Sun 17. Aug 22:33:08 2008
    5. ** by: Qt User Interface Compiler version 4.4.1
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling ui file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_JANELA_H
    11. #define UI_JANELA_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QMainWindow>
    18. #include <QtGui/QMenu>
    19. #include <QtGui/QMenuBar>
    20. #include <QtGui/QStatusBar>
    21. #include <QtGui/QToolBar>
    22. #include <QtGui/QWidget>
    23.  
    24. QT_BEGIN_NAMESPACE
    25.  
    26. class Ui_mainWindow
    27. {
    28. public:
    29. QAction *actionNovo;
    30. QAction *actionAbrir;
    31. QAction *actionSobre;
    32. QAction *actionGuardar;
    33. QAction *actionGuardar_Como;
    34. QWidget *centralwidget;
    35. QMenuBar *menubar;
    36. QMenu *menuSobre;
    37. QMenu *menuFile;
    38. QStatusBar *statusbar;
    39. QToolBar *toolBar;
    40.  
    41. void setupUi(QMainWindow *mainWindow)
    42. {
    43. if (mainWindow->objectName().isEmpty())
    44. mainWindow->setObjectName(QString::fromUtf8("mainWindow"));
    45. mainWindow->resize(438, 418);
    46. QIcon icon;
    47. icon.addPixmap(QPixmap(QString::fromUtf8("../../../../Documents and Settings/Joao/.designer/backup/images/icon.png")), QIcon::Normal, QIcon::Off);
    48. mainWindow->setWindowIcon(icon);
    49. actionNovo = new QAction(mainWindow);
    50. actionNovo->setObjectName(QString::fromUtf8("actionNovo"));
    51. QIcon icon1;
    52. icon1.addPixmap(QPixmap(QString::fromUtf8("images/new.png")), QIcon::Normal, QIcon::Off);
    53. actionNovo->setIcon(icon1);
    54. actionAbrir = new QAction(mainWindow);
    55. actionAbrir->setObjectName(QString::fromUtf8("actionAbrir"));
    56. QIcon icon2;
    57. icon2.addPixmap(QPixmap(QString::fromUtf8("images/open.png")), QIcon::Normal, QIcon::Off);
    58. actionAbrir->setIcon(icon2);
    59. actionSobre = new QAction(mainWindow);
    60. actionSobre->setObjectName(QString::fromUtf8("actionSobre"));
    61. actionGuardar = new QAction(mainWindow);
    62. actionGuardar->setObjectName(QString::fromUtf8("actionGuardar"));
    63. QIcon icon3;
    64. icon3.addPixmap(QPixmap(QString::fromUtf8("images/save.png")), QIcon::Normal, QIcon::Off);
    65. actionGuardar->setIcon(icon3);
    66. actionGuardar_Como = new QAction(mainWindow);
    67. actionGuardar_Como->setObjectName(QString::fromUtf8("actionGuardar_Como"));
    68. centralwidget = new QWidget(mainWindow);
    69. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    70. mainWindow->setCentralWidget(centralwidget);
    71. menubar = new QMenuBar(mainWindow);
    72. menubar->setObjectName(QString::fromUtf8("menubar"));
    73. menubar->setGeometry(QRect(0, 0, 438, 21));
    74. menuSobre = new QMenu(menubar);
    75. menuSobre->setObjectName(QString::fromUtf8("menuSobre"));
    76. menuFile = new QMenu(menubar);
    77. menuFile->setObjectName(QString::fromUtf8("menuFile"));
    78. mainWindow->setMenuBar(menubar);
    79. statusbar = new QStatusBar(mainWindow);
    80. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    81. mainWindow->setStatusBar(statusbar);
    82. toolBar = new QToolBar(mainWindow);
    83. toolBar->setObjectName(QString::fromUtf8("toolBar"));
    84. mainWindow->addToolBar(Qt::TopToolBarArea, toolBar);
    85.  
    86. menubar->addAction(menuFile->menuAction());
    87. menubar->addAction(menuSobre->menuAction());
    88. menuSobre->addAction(actionSobre);
    89. menuFile->addAction(actionNovo);
    90. menuFile->addAction(actionAbrir);
    91. menuFile->addAction(actionGuardar);
    92. menuFile->addAction(actionGuardar_Como);
    93. toolBar->addAction(actionNovo);
    94. toolBar->addAction(actionAbrir);
    95. toolBar->addAction(actionGuardar);
    96.  
    97. retranslateUi(mainWindow);
    98.  
    99. QMetaObject::connectSlotsByName(mainWindow);
    100. } // setupUi
    101.  
    102. void retranslateUi(QMainWindow *mainWindow)
    103. {
    104. mainWindow->setWindowTitle(QApplication::translate("mainWindow", "Janela", 0, QApplication::UnicodeUTF8));
    105.  
    106. #ifndef QT_NO_TOOLTIP
    107. mainWindow->setToolTip(QApplication::translate("mainWindow", "Janela", 0, QApplication::UnicodeUTF8));
    108. #endif // QT_NO_TOOLTIP
    109.  
    110.  
    111. #ifndef QT_NO_STATUSTIP
    112. mainWindow->setStatusTip(QApplication::translate("mainWindow", "status janela", 0, QApplication::UnicodeUTF8));
    113. #endif // QT_NO_STATUSTIP
    114.  
    115. actionNovo->setText(QApplication::translate("mainWindow", "Novo", 0, QApplication::UnicodeUTF8));
    116. actionAbrir->setText(QApplication::translate("mainWindow", "Abrir", 0, QApplication::UnicodeUTF8));
    117. actionSobre->setText(QApplication::translate("mainWindow", "Sobre", 0, QApplication::UnicodeUTF8));
    118. actionGuardar->setText(QApplication::translate("mainWindow", "Guardar", 0, QApplication::UnicodeUTF8));
    119. actionGuardar_Como->setText(QApplication::translate("mainWindow", "Guardar Como", 0, QApplication::UnicodeUTF8));
    120. menuSobre->setTitle(QApplication::translate("mainWindow", "Sobre", 0, QApplication::UnicodeUTF8));
    121. menuFile->setTitle(QApplication::translate("mainWindow", "File", 0, QApplication::UnicodeUTF8));
    122. toolBar->setWindowTitle(QApplication::translate("mainWindow", "toolBar", 0, QApplication::UnicodeUTF8));
    123.  
    124. #ifndef QT_NO_STATUSTIP
    125. toolBar->setStatusTip(QApplication::translate("mainWindow", "status janela", 0, QApplication::UnicodeUTF8));
    126. #endif // QT_NO_STATUSTIP
    127.  
    128. } // retranslateUi
    129.  
    130. };
    131.  
    132. namespace Ui {
    133. class mainWindow: public Ui_mainWindow {};
    134. } // namespace Ui
    135.  
    136. QT_END_NAMESPACE
    137.  
    138. #endif // UI_JANELA_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 19th August 2008 at 19:56. Reason: missing [code] tags

  11. #11
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Icons dont apear in tolbar

    try this example.
    Attached Files Attached Files
    • File Type: zip t.zip (3.4 KB, 12 views)

  12. The following user says thank you to spirit for this useful post:

    john_god (19th August 2008)

  13. #12
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Thumbs up Re: Icons dont apear in tolbar

    Thank a lot spirit that works . I gonna studdy the two ui files, to see the diferences.

    But I steel dont know what i am doing wrong

  14. #13
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Smile Re: Icons dont apear in tolbar

    I 've delete all icons and action in the designer, and then add all again. It works fine now.
    Thank you all for the help

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.