PDA

View Full Version : Image on Splitter



moizahamedv
3rd March 2006, 13:26
hi,

QVBoxLayout *v=new QVBoxLayout(this);
QSplitter *splitter=new QSplitter(this);
splitter->setOrientation(Qt::Vertical);
QPixmap pixmap("Album.png");
splitter->setHandleWidth(pixmap.width());
QLabel* label = new QLabel(splitter->handle(2));
label->setPixmap(pixmap);
QLineEdit *l1=new QLineEdit();
QLineEdit *l2=new QLineEdit();
QLineEdit *l3=new QLineEdit();

bool p=pixmap.isNull();
splitter->addWidget(l1);
splitter->addWidget(l2);
splitter->addWidget(l3);
v->addWidget(splitter);

splitter handle width is equal to the image width,,,,....

But unable to get the image on to the splitter handle...

help plz..

thx

jpn
3rd March 2006, 13:40
First, don't start new threads on the same topic. Secondly, use code-tags around your code postings to make it more readable, please.

Just for testing purposes, try adding that label with the pixmap to the splitter as a widget, instead of constructing it as a child of the handle. Can you then see the image?

A side note: For a vertical orientation you might want to use pixmap's height as handle width.

moizahamedv
3rd March 2006, 14:00
Hi,

Yes if i add label with pixmap as a widget then i am able to see the image....Fine...But i want that image to be in the splitter handle...


Thx

jpn
3rd March 2006, 14:10
Ok. Maybe the index of the handle is wrong or the child-parent relationship between the label and the handle is messed.

Try adding labels with the image on every handle: :p


int i = 0;
while (splitter->handle(i))
{
QLabel* label = new QLabel(splitter->handle(i));
label->setPixmap(pixmap);
++i;
}


Btw, I tested setting a pixmap in the splitter handle in win and linux environments and both worked for me (Qt 4.1.1)..
(Except that handle width didn't change on linux but I still was able to see the pixmap though..)

jpn
3rd March 2006, 15:40
Isn't this more or less what you are looking for?