Qt-interest Archive, March 2007
setWindowIcon
Message 1 in thread
Hi,
I am having trouble setting an icon on the top left corner of the window. My
code doesn't give any errors, but also doesn't show the icon. Instead it
shows the default icon. I am using Qt 4.1 on windows XP Pro with VS 2005
Pro.Here's what I am doing:
--------
QWidget * window;
window->setWindowTitle("my application");
window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
--------
Can anyone plz. guide me as what's going wrong here and how to fix it?
Thanks,
Ashish
Message 2 in thread
make sure you give the right path, have the icon list in the .prc,
redo the make process.
> Hi,
>
> I am having trouble setting an icon on the top left corner of the window.
> My
> code doesn't give any errors, but also doesn't show the icon. Instead it
> shows the default icon. I am using Qt 4.1 on windows XP Pro with VS 2005
> Pro.Here's what I am doing:
> --------
> QWidget * window;
> window->setWindowTitle("my application");
> window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> --------
>
> Can anyone plz. guide me as what's going wrong here and how to fix it?
>
> Thanks,
> Ashish
>
--
[ signature omitted ]
Message 3 in thread
Thanks for replying. I have the right path. But I don't know what is '.prc'
Can you explain a little more plz?
On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>
> make sure you give the right path, have the icon list in the .prc,
> redo the make process.
>
> > Hi,
> >
> > I am having trouble setting an icon on the top left corner of the
> window.
> > My
> > code doesn't give any errors, but also doesn't show the icon. Instead it
> > shows the default icon. I am using Qt 4.1 on windows XP Pro with VS 2005
> > Pro.Here's what I am doing:
> > --------
> > QWidget * window;
> > window->setWindowTitle("my application");
> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> > --------
> >
> > Can anyone plz. guide me as what's going wrong here and how to fix it?
> >
> > Thanks,
> > Ashish
> >
>
>
> --
> Honglin Ye
>
>
Message 4 in thread
I don't mean the icon of the application file, I mean the icon of the
application window. I guess what you suggested is for the first one(correct
me if I am wrong) according to the following doc:
http://doc.trolltech.com/appicon.html
What I want to do is to change the icon on the top left corner of the
application main window. Do I still need to have the icon file in the
RESOURCE section? And btw, I am not using qmake, I am using CMake. How do I
do it? Plz. help.
Thanks,
Ashish
On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>
> Sorry, I mean .qrc file - where you list your resource.
> If you use qmake, make sure have that icon file listed in thre
> RESOURCE section of the .pro
>
>
> > Thanks for replying. I have the right path. But I don't know what is
> > '.prc'
> > Can you explain a little more plz?
> >
> > On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
> >>
> >> make sure you give the right path, have the icon list in the .prc,
> >> redo the make process.
> >>
> >> > Hi,
> >> >
> >> > I am having trouble setting an icon on the top left corner of the
> >> window.
> >> > My
> >> > code doesn't give any errors, but also doesn't show the icon. Instead
> >> it
> >> > shows the default icon. I am using Qt 4.1 on windows XP Pro with VS
> >> 2005
> >> > Pro.Here's what I am doing:
> >> > --------
> >> > QWidget * window;
> >> > window->setWindowTitle("my application");
> >> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> >> > --------
> >> >
> >> > Can anyone plz. guide me as what's going wrong here and how to fix
> it?
> >> >
> >> > Thanks,
> >> > Ashish
> >> >
> >>
> >>
> >> --
> >> Honglin Ye
> >>
> >>
> >
>
>
> --
> Honglin Ye
>
>
Message 5 in thread
1) if you do not use qmake, list your resource in a abc.qrc
file like this:
---------------
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>D:/testimages/img1.jpg</file>
</qresource>
</RCC>
---------------
2) compile with 'rcc abc.qrc'
3) have Q_INIT_RESOURCE(abc); in your app, often in main,
4) compile everything
5) then your setWindowIcon will show that icon topleft
5.5) if not, try with a .png file?
> I don't mean the icon of the application file, I mean the icon of the
> application window. I guess what you suggested is for the first
> one(correct
> me if I am wrong) according to the following doc:
>
> http://doc.trolltech.com/appicon.html
>
> What I want to do is to change the icon on the top left corner of the
> application main window. Do I still need to have the icon file in the
> RESOURCE section? And btw, I am not using qmake, I am using CMake. How do
> I
> do it? Plz. help.
>
> Thanks,
> Ashish
>
> On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>>
>> Sorry, I mean .qrc file - where you list your resource.
>> If you use qmake, make sure have that icon file listed in thre
>> RESOURCE section of the .pro
>>
>>
>> > Thanks for replying. I have the right path. But I don't know what is
>> > '.prc'
>> > Can you explain a little more plz?
>> >
>> > On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>> >>
>> >> make sure you give the right path, have the icon list in the .prc,
>> >> redo the make process.
>> >>
>> >> > Hi,
>> >> >
>> >> > I am having trouble setting an icon on the top left corner of the
>> >> window.
>> >> > My
>> >> > code doesn't give any errors, but also doesn't show the icon.
>> Instead
>> >> it
>> >> > shows the default icon. I am using Qt 4.1 on windows XP Pro with VS
>> >> 2005
>> >> > Pro.Here's what I am doing:
>> >> > --------
>> >> > QWidget * window;
>> >> > window->setWindowTitle("my application");
>> >> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
>> >> > --------
>> >> >
>> >> > Can anyone plz. guide me as what's going wrong here and how to fix
>> it?
>> >> >
>> >> > Thanks,
>> >> > Ashish
>> >> >
>> >>
>> >>
>> >> --
>> >> Honglin Ye
>> >>
>> >>
>> >
>>
>>
>> --
>> Honglin Ye
>>
>>
>
--
[ signature omitted ]
Message 6 in thread
Thanks for replying Honglin. I will try this. Btw, do you know how to do it
with CMake?
Thanks,
Ashish
On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>
> 1) if you do not use qmake, list your resource in a abc.qrc
> file like this:
> ---------------
> <!DOCTYPE RCC><RCC version="1.0">
> <qresource>
> <file>D:/testimages/img1.jpg</file>
> </qresource>
> </RCC>
> ---------------
> 2) compile with 'rcc abc.qrc'
> 3) have Q_INIT_RESOURCE(abc); in your app, often in main,
> 4) compile everything
> 5) then your setWindowIcon will show that icon topleft
> 5.5) if not, try with a .png file?
>
>
> > I don't mean the icon of the application file, I mean the icon of the
> > application window. I guess what you suggested is for the first
> > one(correct
> > me if I am wrong) according to the following doc:
> >
> > http://doc.trolltech.com/appicon.html
> >
> > What I want to do is to change the icon on the top left corner of the
> > application main window. Do I still need to have the icon file in the
> > RESOURCE section? And btw, I am not using qmake, I am using CMake. How
> do
> > I
> > do it? Plz. help.
> >
> > Thanks,
> > Ashish
> >
> > On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
> >>
> >> Sorry, I mean .qrc file - where you list your resource.
> >> If you use qmake, make sure have that icon file listed in thre
> >> RESOURCE section of the .pro
> >>
> >>
> >> > Thanks for replying. I have the right path. But I don't know what is
> >> > '.prc'
> >> > Can you explain a little more plz?
> >> >
> >> > On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
> >> >>
> >> >> make sure you give the right path, have the icon list in the .prc,
> >> >> redo the make process.
> >> >>
> >> >> > Hi,
> >> >> >
> >> >> > I am having trouble setting an icon on the top left corner of the
> >> >> window.
> >> >> > My
> >> >> > code doesn't give any errors, but also doesn't show the icon.
> >> Instead
> >> >> it
> >> >> > shows the default icon. I am using Qt 4.1 on windows XP Pro with
> VS
> >> >> 2005
> >> >> > Pro.Here's what I am doing:
> >> >> > --------
> >> >> > QWidget * window;
> >> >> > window->setWindowTitle("my application");
> >> >> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> >> >> > --------
> >> >> >
> >> >> > Can anyone plz. guide me as what's going wrong here and how to fix
> >> it?
> >> >> >
> >> >> > Thanks,
> >> >> > Ashish
> >> >> >
> >> >>
> >> >>
> >> >> --
> >> >> Honglin Ye
> >> >>
> >> >>
> >> >
> >>
> >>
> >> --
> >> Honglin Ye
> >>
> >>
> >
>
>
> --
> Honglin Ye
>
>
Message 7 in thread
Ok. I got it to work with CMake. Thanks guys.
On 3/8/07, Ashish Singh <mrasingh@xxxxxxxxx> wrote:
>
> Thanks for replying Honglin. I will try this. Btw, do you know how to do
> it with CMake?
>
> Thanks,
> Ashish
>
> On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> >
> > 1) if you do not use qmake, list your resource in a abc.qrc
> > file like this:
> > ---------------
> > <!DOCTYPE RCC><RCC version="1.0">
> > <qresource>
> > <file>D:/testimages/img1.jpg</file>
> > </qresource>
> > </RCC>
> > ---------------
> > 2) compile with 'rcc abc.qrc'
> > 3) have Q_INIT_RESOURCE(abc); in your app, often in main,
> > 4) compile everything
> > 5) then your setWindowIcon will show that icon topleft
> > 5.5) if not, try with a .png file?
> >
> >
> > > I don't mean the icon of the application file, I mean the icon of the
> > > application window. I guess what you suggested is for the first
> > > one(correct
> > > me if I am wrong) according to the following doc:
> > >
> > > http://doc.trolltech.com/appicon.html
> > >
> > > What I want to do is to change the icon on the top left corner of the
> > > application main window. Do I still need to have the icon file in the
> > > RESOURCE section? And btw, I am not using qmake, I am using CMake. How
> > do
> > > I
> > > do it? Plz. help.
> > >
> > > Thanks,
> > > Ashish
> > >
> > > On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> > >>
> > >> Sorry, I mean .qrc file - where you list your resource.
> > >> If you use qmake, make sure have that icon file listed in thre
> > >> RESOURCE section of the .pro
> > >>
> > >>
> > >> > Thanks for replying. I have the right path. But I don't know what
> > is
> > >> > '.prc'
> > >> > Can you explain a little more plz?
> > >> >
> > >> > On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> > >> >>
> > >> >> make sure you give the right path, have the icon list in the .prc,
> > >> >> redo the make process.
> > >> >>
> > >> >> > Hi,
> > >> >> >
> > >> >> > I am having trouble setting an icon on the top left corner of
> > the
> > >> >> window.
> > >> >> > My
> > >> >> > code doesn't give any errors, but also doesn't show the icon.
> > >> Instead
> > >> >> it
> > >> >> > shows the default icon. I am using Qt 4.1 on windows XP Pro with
> > VS
> > >> >> 2005
> > >> >> > Pro.Here's what I am doing:
> > >> >> > --------
> > >> >> > QWidget * window;
> > >> >> > window->setWindowTitle("my application");
> > >> >> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> > >> >> > --------
> > >> >> >
> > >> >> > Can anyone plz. guide me as what's going wrong here and how to
> > fix
> > >> it?
> > >> >> >
> > >> >> > Thanks,
> > >> >> > Ashish
> > >> >> >
> > >> >>
> > >> >>
> > >> >> --
> > >> >> Honglin Ye
> > >> >>
> > >> >>
> > >> >
> > >>
> > >>
> > >> --
> > >> Honglin Ye
> > >>
> > >>
> > >
> >
> >
> > --
> > Honglin Ye
> >
> >
>
Message 8 in thread
Why don't I see this icon when I deploy the application on a different
workstation?
On 3/9/07, Ashish Singh <mrasingh@xxxxxxxxx> wrote:
>
> Ok. I got it to work with CMake. Thanks guys.
>
>
> On 3/8/07, Ashish Singh <mrasingh@xxxxxxxxx> wrote:
> >
> > Thanks for replying Honglin. I will try this. Btw, do you know how to do
> > it with CMake?
> >
> > Thanks,
> > Ashish
> >
> > On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> > >
> > > 1) if you do not use qmake, list your resource in a abc.qrc
> > > file like this:
> > > ---------------
> > > <!DOCTYPE RCC><RCC version="1.0">
> > > <qresource>
> > > <file>D:/testimages/img1.jpg</file>
> > > </qresource>
> > > </RCC>
> > > ---------------
> > > 2) compile with 'rcc abc.qrc'
> > > 3) have Q_INIT_RESOURCE(abc); in your app, often in main,
> > > 4) compile everything
> > > 5) then your setWindowIcon will show that icon topleft
> > > 5.5) if not, try with a .png file?
> > >
> > >
> > > > I don't mean the icon of the application file, I mean the icon of
> > > the
> > > > application window. I guess what you suggested is for the first
> > > > one(correct
> > > > me if I am wrong) according to the following doc:
> > > >
> > > > http://doc.trolltech.com/appicon.html
> > > >
> > > > What I want to do is to change the icon on the top left corner of
> > > the
> > > > application main window. Do I still need to have the icon file in
> > > the
> > > > RESOURCE section? And btw, I am not using qmake, I am using CMake.
> > > How do
> > > > I
> > > > do it? Plz. help.
> > > >
> > > > Thanks,
> > > > Ashish
> > > >
> > > > On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> > > >>
> > > >> Sorry, I mean .qrc file - where you list your resource.
> > > >> If you use qmake, make sure have that icon file listed in thre
> > > >> RESOURCE section of the .pro
> > > >>
> > > >>
> > > >> > Thanks for replying. I have the right path. But I don't know what
> > > is
> > > >> > '.prc'
> > > >> > Can you explain a little more plz?
> > > >> >
> > > >> > On 3/8/07, Honglin Ye < hye@xxxxxxxxxxxx> wrote:
> > > >> >>
> > > >> >> make sure you give the right path, have the icon list in the
> > > .prc,
> > > >> >> redo the make process.
> > > >> >>
> > > >> >> > Hi,
> > > >> >> >
> > > >> >> > I am having trouble setting an icon on the top left corner of
> > > the
> > > >> >> window.
> > > >> >> > My
> > > >> >> > code doesn't give any errors, but also doesn't show the icon.
> > > >> Instead
> > > >> >> it
> > > >> >> > shows the default icon. I am using Qt 4.1 on windows XP Pro
> > > with VS
> > > >> >> 2005
> > > >> >> > Pro.Here's what I am doing:
> > > >> >> > --------
> > > >> >> > QWidget * window;
> > > >> >> > window->setWindowTitle("my application");
> > > >> >> >
> > > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
> > > >> >> > --------
> > > >> >> >
> > > >> >> > Can anyone plz. guide me as what's going wrong here and how to
> > > fix
> > > >> it?
> > > >> >> >
> > > >> >> > Thanks,
> > > >> >> > Ashish
> > > >> >> >
> > > >> >>
> > > >> >>
> > > >> >> --
> > > >> >> Honglin Ye
> > > >> >>
> > > >> >>
> > > >> >
> > > >>
> > > >>
> > > >> --
> > > >> Honglin Ye
> > > >>
> > > >>
> > > >
> > >
> > >
> > > --
> > > Honglin Ye
> > >
> > >
> >
>
Message 9 in thread
Ashish Singh a écrit :
> Why don't I see this icon when I deploy the application on a different
> workstation?
JPEG support is probably built into a plugin, not the Qt library itself.
You'll have to install the JPEG plugin in addition to the Qt DLL on the
target machine.
http://doc.trolltech.com/4.2/deployment-windows.html#qt-plugins
--
[ signature omitted ]
Message 10 in thread
On Thu, 8 Mar 2007, Ashish Singh wrote:
> Thanks for replying. I have the right path. But I don't know what is '.prc'
> Can you explain a little more plz?
yes. i call mine .qrc (Qt resource) files, but the gist is that
it's a listing of external resources (e.g., images) that you'll want
automagically bundled with your application.
a .qrc file of mine looks like:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>images/user.gif</file>
<file>images/user-light.gif</file>
</qresource>
</RCC>
to get that into your project, add something like this to your
.pro file:
RESOURCES += nfs4-acl-editor.qrc
then, in my application, i can refer to those images like:
ui = QIcon(QString(":images/user.gif"));
the leading colon in the filename means that it's bundled as a
resource. and .. shazam, it should work.
good luck,
d
.
_____
david m. richter
CITI -- Center for Information Technology Integration
http://www.citi.umich.edu
> On 3/8/07, Honglin Ye <hye@xxxxxxxxxxxx> wrote:
>>
>> make sure you give the right path, have the icon list in the .prc,
>> redo the make process.
>>
>> > Hi,
>> >
>> > I am having trouble setting an icon on the top left corner of the
>> window.
>> > My
>> > code doesn't give any errors, but also doesn't show the icon. Instead it
>> > shows the default icon. I am using Qt 4.1 on windows XP Pro with VS 2005
>> > Pro.Here's what I am doing:
>> > --------
>> > QWidget * window;
>> > window->setWindowTitle("my application");
>> > window->setWindowIcon(QIcon(QString("D:/testimages/img1.jpg")));
>> > --------
>> >
>> > Can anyone plz. guide me as what's going wrong here and how to fix it?
>> >
>> > Thanks,
>> > Ashish
>> >
>>
>>
>> --
>> Honglin Ye
>>
>>
>
--
[ signature omitted ]