Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QAction don't show the icons
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QAction don't show the icons

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have the problem, and previously i have tried to find a solution but can't solve the problem.

    I found in the web, than the problem is the xubuntu used on my pc.
    Then recomend me configure the gnome with:
    gconftool-2 --type Boolean --set /desktop/gnome/interface/menus_have_icons True
    but all are equall.
    I have a doubt with where establish the files ".png" if it should be on "sources" or "Other Files".
    I did put on "Other Files", but.... Is this correct?
    it seems to had read that I should put it under source, if this is right, could you explain me, how do i put
    the files ".png" under "source"?

    the program is:

    @#ifndef ANOTHERMENU_H
    #define ANOTHERMENU_H

    #include <QMainWindow>
    #include <QApplication>

    class AnotherMenu : public QMainWindow
    {
    public:
    AnotherMenu(QWidget *parent = 0);
    };

    #endif // ANOTHERMENU_H
    @
    @#include "anothermenu.h"
    #include <QMenu>
    #include <QMenuBar>

    AnotherMenu::AnotherMenu(QWidget *parent)
    : QMainWindow(parent)
    {
    QPixmap newpix("new.png");
    QPixmap openpix("open.png");
    QPixmap quitpix("quit.png");

    QAction *newa = new QAction(newpix, "&New", this);
    QAction *open = new QAction(openpix, "&Open", this);
    QAction *quit = new QAction(quitpix, "&Quit", this);
    quit->setShortcut(tr("CTRL+Q"));
    
    QMenu *file;
    file = menuBar()->addMenu("&File");
    file->addAction(newa);
    file->addAction(open);
    file->addSeparator();
    file->addAction(quit);
    
    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()) );
    

    }

    @

    @#include "anothermenu.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    AnotherMenu window;
    
    window.resize(550, 400);
    window.move(300, 300);
    window.setWindowTitle("Another Menu");
    window.show();
    
    
    return a.exec(&#41;;
    

    }@

    All function Ok, less appear the icons.
    Thanks in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure your images are found ? Giving only the name of the file implies that they reside in the same folder as the application

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        When i start a project and in my case named : menus_toolbars2; Creator create two carpets:
        -menus_toolbars2
        -build-menus_toolbars2-Desktop_5_1_0_GCC_64bit-Debug

        When i pasted the 3 files ".png" in the carpet menus_toolbars, i did this initially; and compile/run the program, do not appear the icons in menus.

        But When i pasted the 3 files ".png" in the second carpet, and compile/run the program, NOW already appear the icons in menus

        Thanks Sgaist for help me

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved