开发者

QT background image not showing using stylesheets

I'm using QT for C++ and I se开发者_StackOverflowt this stylesheet code:

QFrame {
    background-image: url(img.png);
}

The image doesn't show! It's located in the debug directory inside the QT directory. Why doesn't it show?

edit:

doesn't even work with the resource system

edit 2:

It shows now, but only if I use QWidget instead of QFrame. The only problem is that the image repeats when I resize the window. How do I make it stretch normally instead?

edit 3:

OK, I used JUST border-image now and it stretches. However, it's glitchy(if you move a bit fast you can go over the original image), and very slow(if you're not resizing slowly enough, it will stutter and until it manages to stretch there will be a white gap). Can't I get it to resize normally? =/

Using this stylesheet code:

QWidget {
border-image: url(:/images/img.png);
}

edit 4:

Well if I'm already at it.. what about clickable areas in images? Is that possible?

edit 5:

come on..anyone? this is important


Add your image to resources (.qrc file) of your application. Then refer to it in your stylesheet:

QFrame
{
 background-image: url(:/Style/img.png);
}


I think you should use Qt Resource System instead of having an image inside the folder. Images can also be speicified without the url function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜