PDA

View Full Version : load pixmap from another host



raphaelf
28th August 2006, 13:45
Hi everybody,

QT: 4.1.3
COMPILER: Mingw
OS: WinXP Pro

My app is able to show and change a pixmap on a QLabel by changing the selection on a Q3ListView. On changing the selection i call this function to show the pixmap:



connect(ui.listView, SIGNAL(selectionChanged ()), this, SLOT(getPicA()));
.
.
.
void MainWindow::getPicA()
{

ui.label->setPixmap(QPixmap(( ui.listView->currentItem() )->text( 4 )));
}


Now my app is runing on another machine. The Picture are saved on the server. (//pcps391/transfer/images/a.jpg).

If i run my app from the server i can see the picture, but if i run my app from another machine i cant see the pic.
ui.listView->currentItem() )->text( 4 ) = "//pcps391/transfer/images/a.jpg".

If i change a item on my Q3ListView i can feel that the app is slower :(


Can somebody see the problem?

gfunk
28th August 2006, 20:55
Have you tried \\pcps391\transfer\images\a.jpg (file://\\pcps391\transfer\images\a.jpg) instead?
ui.listView->currentItem() )->text( 4 ) = "\\\\pcps391\\transfer\\images\\a.jpg"

raphaelf
29th August 2006, 08:28
Hi gFunk,

Itried "\\pcps391\transfer\images\a.jpg" and "\\\\pcps391\\transfer\\images\\a.jpg" but it not works.

If i run my app from the server i can see the picture, but if i run my app from another machine i cant see the pic by using "\\pcps391\transfer\images\a.jpg"

What could i try?

gfunk
29th August 2006, 09:24
Maybe the UNC filenaming isn't working inside Qt? Perhaps try mapping the folder to a drive, and then accessing the file, ie, map \\pcps391\transfer to z:, then access it as z:\images\a.jpg


Or, try copying that file to the machine so that it is local, make sure it isn't a machine-specific problem.

raphaelf
29th August 2006, 10:47
hi gFunk,

I map it to z:\ on the server and on the client..

If i run the app from the server i can see the pic, but if i run it from the client i am not able to see the pic.. :crying:

I cant use the copy solution, because my second step will be to start mp3 files on the client (the files are saved on the server) and i can not copy everytime a file localy on the client
I can not understand why is not working..
Have you another idea??

raphaelf
29th August 2006, 11:20
Hi,

I try again to use : "//pcps391/transfer/images/a.jpg" and check if the file is readable like this:



QFileInfo file(( ui.listView->currentItem() )->text( 4 ));
if(file.isReadable() == true)
{
QMessageBox::information(this, "", ( "true"));
ui.label->setPixmap(QPixmap(( ui.listView->currentItem() )->text( 4 )));
}


THE CLIENT RETURN TRUE, so the client can read the file but are not able to show it..
The same problem i have by trying to play a sound that are saved on the server and execute on the client.. :crying:
Have i a solution on qt4?

wysota
29th August 2006, 12:03
Try copying the pixmap file to a temporary storage on the client before making a pixmap out of it. Maybe there is some bug/feature in QPixmap constructor which prevents it from working on samba shares. You won't lose any performance as the file would have to be copied to the client anyway before creating the pixmap.

raphaelf
29th August 2006, 13:10
Hi wysota,

How i wrote..I cant use this solution because my seconde step will be to play mp3 files on the client (the mp3 files are saved on the server).
I cant copy every file on the client if i want to play a playlist for example..
I think that i have a problem now..

Can you see my problem?

wysota
29th August 2006, 13:30
Hi wysota,

How i wrote..I cant use this solution because my seconde step will be to play mp3 files on the client (the mp3 files are saved on the server).
I cant copy every file on the client if i want to play a playlist for example..
I think that i have a problem now..

Can you see my problem?

If you want to access them, they have to be transfered to the client over the network anyway. You can't just "magically" play them without transfering data between hosts. So the only difference is that copying to a temporary file requires a bit of disk (or ramdisk) space on the client machine. The gain, on the other hand, is that each file will be transfered only once, no matter how many times you want to play it. As for MP3, I doubt you'll be using Qt for that directly, so maybe playing over network will work just fine with the method you choose. As I said before, the problem might be in the QPixmap constructor.

raphaelf
29th August 2006, 14:40
Hi wysota,

I tryed to play a song on the client and it works over the network. The song is saved on the server and i could listen on the client..

Why qpixmap has this bug :confused: :crying:

Could i use another QTQ Element for showing jpg files over the network?
I need just to show a picture by selecting a album..

wysota
29th August 2006, 18:41
Why qpixmap has this bug :confused: :crying:
Hard to say. The bug is probably not in QPixmap but in QImageLoader.


Could i use another QTQ Element for showing jpg files over the network?
I need just to show a picture by selecting a album..
You can always subclass QImageLoader (if it is the component causing the faulty behaviour) and fix the bug.

raphaelf
30th August 2006, 08:15
Hi Wysota,
I dont know how to fix it wysota, i have not experience for that :crying:
I have just a litle experience on QT3 and now Qt4
Now i have really a problem..Because i need a solution for my diploma :crying: and i have not a lot of time to fix this bug..
Do you mean QImageReader?I cant find QImageLoader :o

My idea was to save everything on a server (pics and mp3 files) and install my app on 5 clients that are able to get pics and mp3 files from the server and play it..
I can play mp3 that are saved on the server without problems on the client..
Now i just need a solution to show album pics on the client that are saved on the server..
I have a database and a complicated structure behind, so it will be very complex to copy this pics everytime on the client and show it..


Have you another idea how to show this pics on the client via network?

wysota
30th August 2006, 10:39
Have you another idea how to show this pics on the client via network?

Open the image as a file, read its contents and construct the pixmap using QPixmap::loadFromData().

raphaelf
31st August 2006, 08:55
Hi wisota,
thanks..I try to copy the picture localy and show it..it works fine..
I think it will be not easy to read content and loadfromData...do you know if i could find a example for that?
Its important that it works..
of course if i could open directly from the server and show it, it could be most beautifull..
:p

thanks to all

wysota
31st August 2006, 11:50
I think it will be not easy to read content and loadfromData...
Why so? What's hard in that?


do you know if i could find a example for that?
Do you really need an example for using a single function call? Here is a pseudo-algo:
1. Open a remote file
2. Use QFile::readAll() to read contents into a byte array
3. create an empty QPixmap object
4. fill the pixmap using loadFromData from the byte array
5. Display your pixmap

raphaelf
31st August 2006, 13:14
Hi wisota,

Ok i will try ;)
I couldnt find QFile::readAll(). Did you mean QFile::open ??

wysota
31st August 2006, 23:58
Hi wisota,

Ok i will try ;)
I couldnt find QFile::readAll(). Did you mean QFile::open ??

No, I meant File::readAll(). It's inherited from QIODevice (see QIODevice::readAll()).