PDA

View Full Version : To put Image on QSplitter



moizahamedv
3rd March 2006, 10:48
Hi Sir,

I just want to draw an image or an pixmap on to the QSplitter ..How to do that...I am

Fixed over this issue ,unable to move forward....Please help me out...



Thanks

dublet
3rd March 2006, 10:54
In the QSplitter, add a custom QWidget which uses a QImage to draw in it's repaint methods.

jpn
3rd March 2006, 10:58
What is it exactly you're trying to do?
Are you trying to show an image as one of the widgets handled by a splitter, or customizing the look of the "splitter divider"?

Edit: ..and which version of Qt are you using, by the way?

moizahamedv
3rd March 2006, 11:02
Hi,
Yes....I want to customize the look of the "splitter divider in image...

jpn
3rd March 2006, 11:21
Well, this kind of trick works in Qt 4.



QPixmap pixmap("test.png");
splitter->setHandleWidth(pixmap.width());
QLabel* label = new QLabel(splitter->handle(1));
label->setPixmap(pixmap);


Note the index of the handle. The pixmap appears in the top area of the handle, to customize to positioning you can use layouts, of course.. ;)

moizahamedv
3rd March 2006, 11:22
I am using Qt 4.1

moizahamedv
3rd March 2006, 11:39
hi,

But I am unable to get the Pixmap on to the splitter handle.....

jpn
3rd March 2006, 11:43
1) Are you sure you are loading the pixmap correctly? Check what pixmap.isNull() returns.
2) Are you sure you are using the correct handle index?

moizahamedv
3rd March 2006, 11:48
hi,

QVBoxLayout *v=new QVBoxLayout(this);
QLineEdit *l1=new QLineEdit(this);
QLineEdit *l2=new QLineEdit(this);
QPixmap pixmap("Album.png");

QSplitter *splitter=new QSplitter();
splitter->setHandleWidth(pixmap.width());
QLabel* label = new QLabel(splitter->handle(1));
label->setPixmap(pixmap);
splitter->addWidget(l1);
splitter->addWidget(l2);
v->addWidget(splitter);

1.Yes,pixmap is loaded successfully....
The code is shown above...
I want the pixmap to be on the splitter....

Thanks

jpn
3rd March 2006, 11:54
I'm quite sure it's about the pixmap. Is it in the same dir than the executable is? Did you check what pixmap.isNull() returns? At least for me, the code I posted earlier, works fine.

moizahamedv
3rd March 2006, 12:05
hi,

The handlewidth is same as that of the image but unable to get the image picture...


Also pixmap.isNull() is returning false....

Thanks...