PDA

View Full Version : How to escape from image background?



chong_kimkeang
10th October 2012, 03:44
I created image background by border_image to make it zoom-able but whenever I create lineEdit,, Menu, or other things, the background still exist in those tool. How can I make other too empty of background that I have created? 8298

wysota
10th October 2012, 08:29
How exactly did you apply the background?

chong_kimkeang
10th October 2012, 08:34
Thanks, but now I found the solution and now a new trouble is I have a label that containing image and whenever I re-size the form I want the background and the label re-size together. Could you give me advises?

I apply it
this->setStyleSheet("border-image: url(:/testLoadImage/C:/Users/kimkeang/Pictures/bc-black-ui.png)");

wysota
10th October 2012, 08:44
Thanks, but now I found the solution and now a new trouble is I have a label that containing image and whenever I re-size the form I want the background and the label re-size together. Could you give me advises?
Is the label in a layout?


I apply it
this->setStyleSheet("border-image: url(:/testLoadImage/C:/Users/kimkeang/Pictures/bc-black-ui.png)");
That's wrong because it also applies to child widgets. You need a selector (e.g. by id or by class) that will only pick the widget you want.

chong_kimkeang
10th October 2012, 09:01
My code is:


#include "testloadimage.h"

testLoadImage::testLoadImage(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
ui.setupUi(this);
QPixmap bac_image(":/testLoadImage/C:/Users/kimkeang/Pictures/bc-black-ui.png");
this->setStyleSheet("border-image: url(:/testLoadImage/C:/Users/kimkeang/Pictures/bc-black-ui.png)");
QPixmap pix(":/C:/Users/kimkeang/Pictures/blank-canvas.png");

ui.label->setPixmap(pix);


ui.label->setGeometry(QRect(180,100,pix.width(),pix.height() ));
ui.label->adjustSize();
resize(bac_image.width(), bac_image.height());
}


whenever I re-size the form, I need the background and the label re-size too.


Can you tell me more specific?

wysota
10th October 2012, 09:07
This doesn't state whether you are using layouts or not. Looking at line #14 of your snippet, I'm assuming that not. So go back to Designer and apply a layout to your form.

chong_kimkeang
10th October 2012, 09:16
use QFormLayout, QGridLayout or which layout? and If I use layout, I can re-size the label but the label will be swipe-able(to left or to right) because I will make it swipe-able. Which solution should I use?

wysota
10th October 2012, 09:18
use QFormLayout, QGridLayout or which layout?
Whichever you want and whichever suits your purpose, I don't care.

and If I use layout, I can re-size the label but the label will swipe-able(to left or to right).
Good for you.

chong_kimkeang
10th October 2012, 09:20
Can I swipe the label if I use layout?

wysota
10th October 2012, 09:25
Can I swipe the label if I use layout?

Not directly.

chong_kimkeang
10th October 2012, 09:34
Not directly? what is not direct? only this two worlds I can do nothing. Can you kindly tell me or give me ways?

wysota
10th October 2012, 11:17
Not directly? what is not direct? only this two worlds I can do nothing. Can you kindly tell me or give me ways?

I already have in the other thread. Use QML.

chong_kimkeang
11th October 2012, 02:52
You are very kind thank you very mcuh.:o