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. Put one icon to my program with Qt
QtWS25 Last Chance

Put one icon to my program with Qt

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 991 Views
  • 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.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by RIVOPICO
    #1
    This post is deleted!
    VRoninV 1 Reply Last reply
    0
    • joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      @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.

      Just do it!

      RIVOPICOR 1 Reply Last reply
      0
      • joeQJ joeQ

        @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.

        RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by
        #3

        @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) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
            connect (ui->botonExaminar1,SIGNAL(clicked()),this,SLOT(examinar1()));
            connect (ui->botonExaminar2,SIGNAL(clicked()),this,SLOT(examinar2()));
            connect (ui->botonUnir,SIGNAL(clicked()),this,SLOT(juntar()));
        }
        
        MainWindow::~MainWindow()
        {
            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"));
            archivoEjecutable1->setFileName(ui->ejecutable1Texto->text());
            archivoEjecutable2->setFileName(ui->ejecutable2Texto->text());
            archivoStub->setFileName("./stubb.dat");
        
            /* abrir ficheros */
            archivoSalida.open(QFile::WriteOnly);
            archivoEjecutable1->open(QFile::ReadOnly);
            archivoEjecutable2->open(QFile::ReadOnly);
            archivoStub->open(QFile::ReadOnly);
        
            /* escribir en el fichero de salida los tres ejecutables */
            archivoSalida.write(archivoStub->readAll() + archivoEjecutable1->readAll() + archivoEjecutable2->readAll());
        
            /* Convertir los tamaños a QString */
            tamano1.setNum(archivoStub->size());
            tamano2.setNum(archivoEjecutable1->size());
            tamano3.setNum(archivoEjecutable2->size());
        
            /* 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 */
            archivoSalida.write(trama,1024);
        
            /* Cerrar todos los ficheros */
            archivoEjecutable1->close();
            archivoEjecutable2->close();
            archivoStub->close();
        }
        

        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?

        1 Reply Last reply
        0
        • RIVOPICOR Offline
          RIVOPICOR Offline
          RIVOPICO
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • RIVOPICOR RIVOPICO

            This post is deleted!

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @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

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2

            • Login

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