How to setting the background-image





  • Hi,
    What code do you use? What settings?
    The mistake often made is that people use the
    background image in the stylesheet, but you should use the border-image option. Then the image will be resized with the widget size.
    @
    // Setup the border-image as the selected image
    QString strStyle("");

            strStyle.clear();
            strStyle.append("QFrame{border-image: url(");
            strStyle.append(strPicture);   // = ":/BackGroundPictures/BackGroundPictures/M01DrukSensor.PNG"
            strStyle.append(");");
            strStyle.append("}");
    
            pFrame->setStyleSheet(strStyle);
    

    @



  • thank you, but your way is not my want to effect!
    my view is the image no resize!use other color fill the widget!
    how to use the "paintevent" to achieve this effect!
    I want to second effect!
    [quote author="Jeroentje@home" date="1376649188"]Hi,
    What code do you use? What settings?
    The mistake often made is that people use the
    background image in the stylesheet, but you should use the border-image option. Then the image will be resized with the widget size.
    @
    // Setup the border-image as the selected image
    QString strStyle("");

            strStyle.clear();
            strStyle.append("QFrame{border-image: url(");
            strStyle.append(strPicture);   // = ":/BackGroundPictures/BackGroundPictures/M01DrukSensor.PNG"
            strStyle.append(");");
            strStyle.append("}");
    
            pFrame->setStyleSheet(strStyle);
    

    @[/quote]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.