Welcome! Log In Create A New Profile


Assignment 1...????

Posted by tshax 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 1...????
January 18, 2010 04:24PM
I am triying to copy a picture into a program but is not showing. The code from the assignment where i think it must be inserted a picture is:
QPixmap pixmap(../Photo.jpg);...
avatar Re: Assignment 1...????
January 18, 2010 04:42PM
Then try inserting the whole filepath in there. I think Vista also has a similar quibble.


QPixmap pixmap("C:/blabla/blabla/Photo.jpg"winking smiley;
Re: Assignment 1...????
January 19, 2010 08:48AM
It did work, now am done with assignment 01.....
smileys with beer
Re: Assignment 1...????
January 29, 2010 07:27AM
Thanks Jgrand0.
Anonymous User
Re: Assignment 1...????
February 17, 2010 05:54PM
I tried to give full path and even changing the slashes forward and backward and it did not work for me. I am getting the error Collect 2: Id returned 1 exit status. Would you please help me. It s getting late and I am worried.I am using XP in machine and Vista in another machins but it is not working in both.
avatar Re: Assignment 1...????
February 17, 2010 08:28PM
Is the problem just related to the picture ie does it work without the pic? If with the pic, Is your pict in the same folder as the program?
avatar Re: Assignment 1...????
February 17, 2010 08:57PM
Not sure if it helps but mine wasn't able to compile until i shortend the project directory path where main.cpp and photo.jpg were located...
C:\bla\bla\bla\bla\bla\bla\bla\bla> was giving issues, not sure why but when i changed the project folder to
C:\bla\bla> ie C:\UNISA\COS2144> it compiled fine after that?
Anonymous User
Re: Assignment 1...????
February 18, 2010 08:48AM
hi friend,
I typed as it is given in the assignment. Can you please tell me how to check without inserting the picture. the picture is in the folder. The command I used is this:

QPixmap pixmap("D:/wise_2009_unisa/youth/photo.jpg"winking smiley;
QLabel pixmapLabel;

I have photo.jpg in the folder youth. but I cannot see in the open folders in Qt. I opened My Computer and I can see it there.
Re: Assignment 1...????
February 18, 2010 02:31PM
I copied the code as is given in the assignment. Copied a random photo to the C:\Unisa\COS214 like Travis has. It gave me an error first but when changing one of the slashes it worked. I'm don't have my app with me now, but if I remember correctly I actually have to opposite slashes in my directory. But I will have to confirm that later tonight. But otherwise it works just fine now.

I agree with Travis: Rather just copy it to where you do your projects, preferably with an easier path. That way you decrease your chances of errors.
avatar Re: Assignment 1...????
February 18, 2010 07:27PM
If your photo is in folder youth, then use "../photo.jpg"... that is assuming your picture is called photo.jpg.
To remove the line place/* before it and */ after it...
Re: Assignment 1...????
February 18, 2010 10:56PM
I checked my path.. It's "C:/Unisa/Winter.jpeg"
Anonymous User
Re: Assignment 1...????
February 18, 2010 11:06PM
THANX TO EVERYONE. I could build the program. Now my problem is it is not running. error code 255. microsoft error. I am using vista home edition. Any idea to go about
Anonymous User
Re: Assignment 1...????
February 18, 2010 11:19PM
hi, thanx. i tried ur way of giving path. its fine its compiling but not running. giving microsoft windows stopped working. code 255. i keep trying. tell me if u know what shold i do
Re: Assignment 1...????
February 18, 2010 11:28PM
Not to sure about that one. I do my Qt coding on my XP machine. I tried googling it and gave me one hit that mentioned something about the file could not be found. Just make double sure again that you have the correct filepath. Recheck the code that you copied from the book also.
Anonymous User
Re: Assignment 1...????
February 19, 2010 06:14AM
I did it. using perr to peer I loaded the Qt into another machine with XP. It worked in Xp. I struggled a lot in vista. I did it finally and managed to send it . U were so helpful.Thank you so much.
avatar Re: Assignment 1...????
March 31, 2010 10:06PM
The direction of your slashes is very important in C and C++. If you recall from COS111/112, there are a number of escape characters that rely on the back-slash in order to be inserted into the string. Thus, if you want the back-slash itself, you need to double it first. eg. if your path is C:\mydata\photo.jpeg, then your C++ string must be "C:\\mydata\\photo.jpeg"

To be safe, you can just keep it in UNIX-style using the forward slash. Most file paths get parsed by QDir anyway using the QDir::fromNativeSeparators or QDir::toNativeSeparators functions so the operating system will always get the correct slashes.
Sorry, only registered users may post in this forum.

Click here to login