Important: Please read the Qt Code of Conduct -

Put one icon to my program with Qt

  • This post is deleted!

  • @RIVOPICO Hi, friend, welcome.

    First, modify your qt pro file. add line , like following

    RC_ICONS = app.ico

    the app.ico is one ico file which you want to show in your program.

    and then, put the ico file with qt pro file in same file folder.

    good luck.

  • @joeQ Yeah but i did something like binder. I join different files in one single because it's more comfortable to have only in one. But my question i join diffeent files in only one. But when i try to put some icon the other files are corrupted why? because change me the resources of all files in my new file. I put source to understand what i'm trying to do:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QFileDialog>
    #include <QFile>
    #include <QTextStream>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        connect (ui->botonExaminar1,SIGNAL(clicked()),this,SLOT(examinar1()));
        connect (ui->botonExaminar2,SIGNAL(clicked()),this,SLOT(examinar2()));
        connect (ui->botonUnir,SIGNAL(clicked()),this,SLOT(juntar()));
        delete ui;
    void MainWindow::examinar1()
        ui->ejecutable1Texto->setText(QFileDialog::getOpenFileName(this,"Abrir archivo"));
    void MainWindow::examinar2()
        ui->ejecutable2Texto->setText(QFileDialog::getOpenFileName(this,"Abrir archivo"));
    void MainWindow::juntar()
        /** función para juntar los dos ejecutables **/
        /* declaraciones */
        QFile archivoSalida;
        QFile *archivoEjecutable1;
        QFile *archivoEjecutable2;
        QFile *archivoStub;
        QByteArray tamano1;
        QByteArray tamano2;
        QByteArray tamano3;
        QByteArray trama(1024,'0');
        QString nombreEjecutable1;
        QString nombreEjecutable2;
        /* inicializaciones */
        archivoEjecutable1 = new QFile();
        archivoEjecutable2 = new QFile();
        archivoStub = new QFile();
        /* establecer nombres de los ficheros */
        archivoSalida.setFileName(QFileDialog::getSaveFileName(this,"Archivo de salida"));
        /* abrir ficheros */;
        /* escribir en el fichero de salida los tres ejecutables */
        archivoSalida.write(archivoStub->readAll() + archivoEjecutable1->readAll() + archivoEjecutable2->readAll());
        /* Convertir los tamaños a QString */
        /* Cojer los nombres de los ejecutables */
        nombreEjecutable1 = archivoEjecutable1->fileName().split(QDir::separator()).last();
        nombreEjecutable2 = archivoEjecutable2->fileName().split(QDir::separator()).last();
        /* Crear la trama de datos */
        trama = tamano1 + "|@|" + tamano2 + "|@|" + tamano3 + "|@|" + nombreEjecutable1.toLatin1() + "|@|" + nombreEjecutable2.toLatin1();
        /* Escribir la trama en los últimos 1024 bytes del archivo de salida */
        /* Cerrar todos los ficheros */

    My problem is in archivoSalida i want to put some icon without damage my other files joined in archivosalida. Archivosalida is the output file and contain's all my files. So i want to modify the icon of this only file. Why? Because when i join all files in archivosalida and change the icon of archivosalida, then the other are corrupted because i change the resources of all. So someway to change icon of one file without damage resources of my other files joined or put some icon to my output file (archivosalida). You understand?

  • I'm having problem's with resources files in Qt when i change the resources in one file the other files change the resources of them and they are corrupted again.

  • @RIVOPICO said in Put one icon to my program with Qt:

    some way to assign some icon in some file that i'm working with it in qt with qfile

    There is no cross platform way of doing this, I'm afraid you'll have to rely on the API of your operating system rather than Qt

Log in to reply