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] How to overlap images with resizing in a broken layout qframe

[SOLVED] How to overlap images with resizing in a broken layout qframe

Scheduled Pinned Locked Moved General and Desktop
qframeqlabellayoutoverlapresize
14 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.
  • mrjjM mrjj

    Hi and welcome
    The QLabel will be fit to the image size and not the other way around. (sadly)
    If you want to keep the image with in a some box, you must re-size it your self.

    QPixmap p( QString(":/dog.png") );
    int w = label->width();
    int h = label->height();
    // set a scaled pixmap to a w x h box keeping its aspect ratio 
    label->setPixmap(p.scaled(w,h,Qt::KeepAspectRatio));
    

    Note that you should the the MaximumHeight of the QLabel (with the dog) to the max size you think it should have before
    setting the image. (label->setMaximumHeigh( xxx) )

    X Offline
    X Offline
    xyz0k
    wrote on last edited by
    #3

    Hi @mrjj,

    Thank you fer helping me. Your solution works, even though as the dog's Image needs to be bigger as there will be some details that needs to be showed clearly.

    I tried to increase the available space (reducing the spacing between the horizontal spacers) but the result is still being the same (like if the change does not were done).

    Any Idea?

    Thank you for your help and time.

    Best regards.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #4

      Hi

      Well im not 100% sure how you setup the inner box.
      if you want frameAnimalConatiner to be bigger, you could set its MinimumWidth or height and
      spacers will follow that.

      Are you planning on animation later on ?

      1 Reply Last reply
      1
      • X Offline
        X Offline
        xyz0k
        wrote on last edited by
        #5

        Perfect! You are right, I don't know why it wasn't working but it works now.

        Thank you so much.

        P.D: No, the images are going to be static.

        Cheers.

        mrjjM 1 Reply Last reply
        0
        • X xyz0k

          Perfect! You are right, I don't know why it wasn't working but it works now.

          Thank you so much.

          P.D: No, the images are going to be static.

          Cheers.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @xyz0k
          Super!
          well layouts are funky. And smart.

          Ok. Since you just did not take an image program and made
          one new picture with all in it, I assume you
          going to use different images overlaid ?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sohyun
            wrote on last edited by
            #7

            When a picture file that I bring in from Windows is imported into qt, it breaks. What should I do?

            mrjjM 1 Reply Last reply
            0
            • S sohyun

              When a picture file that I bring in from Windows is imported into qt, it breaks. What should I do?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @sohyun
              breaks in what way?
              Can you upload the picture to postimage.org and post link here ?

              S 1 Reply Last reply
              0
              • mrjjM mrjj

                @sohyun
                breaks in what way?
                Can you upload the picture to postimage.org and post link here ?

                S Offline
                S Offline
                sohyun
                wrote on last edited by
                #9

                @mrjj ![alt text](image url)0_1502204401600_mmmmmmmm.png
                left thing is on window, right thing is qt in Linux.
                I can't handle it.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  Hmm. that is odd.
                  Do you load the same image file on both platforms?
                  What is the format ? (jpg,png) etc.

                  Can you upload the original image so i can try in my linux box?
                  Maybe a support SO has issues on your box or something like that.

                  S 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Hmm. that is odd.
                    Do you load the same image file on both platforms?
                    What is the format ? (jpg,png) etc.

                    Can you upload the original image so i can try in my linux box?
                    Maybe a support SO has issues on your box or something like that.

                    S Offline
                    S Offline
                    sohyun
                    wrote on last edited by
                    #11
                    This post is deleted!
                    mrjjM 1 Reply Last reply
                    0
                    • S sohyun

                      This post is deleted!

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @sohyun
                      Hi
                      I tried in Qt 5.7 on Mint/ubuntu linux and it was shown as
                      expected. ( not broken)

                      I put the image in res file and showed it on a label.

                      Do yo use QImage or how do you show it ?

                      S 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @sohyun
                        Hi
                        I tried in Qt 5.7 on Mint/ubuntu linux and it was shown as
                        expected. ( not broken)

                        I put the image in res file and showed it on a label.

                        Do yo use QImage or how do you show it ?

                        S Offline
                        S Offline
                        sohyun
                        wrote on last edited by
                        #13

                        @mrjj oops, I had a mistake. Widget form has a dot. so it seems to have appeared.
                        if it occurs again, I will ask something someday. :)
                        thank your helping :)
                        Have a nice day!

                        mrjjM 1 Reply Last reply
                        1
                        • S sohyun

                          @mrjj oops, I had a mistake. Widget form has a dot. so it seems to have appeared.
                          if it occurs again, I will ask something someday. :)
                          thank your helping :)
                          Have a nice day!

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          @sohyun

                          oh, so it was not the image that was broken?
                          super
                          Nice day to you too

                          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