Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] widget , background-images , size ;

[SOLVED] widget , background-images , size ;

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 6.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    solo117117
    wrote on last edited by
    #1

    hi

    @ ui->widget->setStyleSheet(" background-image: url(pictures/picture.png); ");
    @

    i want that my picture.png have a precise size

    thank you :)

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      How about more details about this question ? It helps us.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        I guess you need to use "background-clip":http://qt-project.org/doc/qt-5/stylesheet-reference.html#background-clip-prop
        See "The Box Model":http://qt-project.org/doc/qt-5/stylesheet-customizing.html#the-box-model for more details.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          solo117117
          wrote on last edited by
          #4

          my picture have 800 width and 500 height
          I want every time I resize the screen picture (background image ) is automatically resized
          my code

          @void Menu::resizeEvent(QResizeEvent *event)
          {

          ui->widget->setStyleSheet(" background-image: url(pictures/picture.png); ");

          }
          @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            From the doc I sent above:
            [quote]A background-image does not scale with the size of the widget. To provide a "skin" or background that scales along with the widget size, one must use border-image. Since the border-image property provides an alternate background, it is not required to specify a background-image when border-image is specified. In the case, when both of them are specified, the border-image draws over the background-image.[/quote]

            1 Reply Last reply
            0
            • S Offline
              S Offline
              solo117117
              wrote on last edited by
              #6

              thank you, I'll do my best to find a solution .

              i think to use pixmap and label .

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

                Have you tried ?
                @
                ui->widget->setStyleSheet(QStringLiteral("border-image: url(:/pictures/picture.png);"));
                @

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  solo117117
                  wrote on last edited by
                  #8

                  andreyc , thank you very much :) ( verry happy ) .

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andreyc
                    wrote on last edited by
                    #9

                    You are welcome, Glad to help.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved