Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved Layout works on Desktop, but not on Android cell

    Mobile and Embedded
    2
    7
    1401
    Loading More Posts
    • 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.
    • canellas
      canellas last edited by

      Hi,

      The two images attached are of a window written in Qt Widgets, version 5.9.

      The first shows the window when I run the app on my Linux desktop, where the labels with 'play', 'record' and 'stop' images are displayed correctly, but when I run it on Motorola G4, running Android 7.0, the images are displayed as the second image shows.

      Does anyone know why?

      Thanks!!

      0_1505869672331_001.png

      0_1505869686415_002.png

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @canellas last edited by

        @canellas
        what are the types of the images?
        SVGs? PNGs?
        What properties did you set on the QLabels?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • canellas
          canellas last edited by canellas

          Thanks for your time!

          The images are PNG files.

          I attached the image of the .ui file in QtCreator, and I copied the XML part that contains the properties of the widgets, which are based on QLabel, and the widgets around them. I hope that is not too confusing:

          <item row="3" column="0">
               <widget class="QFrame" name="fraPlayRecStop">
                <property name="sizePolicy">
                 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                  <horstretch>0</horstretch>
                  <verstretch>0</verstretch>
                 </sizepolicy>
                </property>
                <property name="frameShape">
                 <enum>QFrame::NoFrame</enum>
                </property>
                <property name="frameShadow">
                 <enum>QFrame::Plain</enum>
                </property>
                <layout class="QHBoxLayout" name="horizontalLayout" stretch="3,4,3">
                 <property name="spacing">
                  <number>1</number>
                 </property>
                 <property name="leftMargin">
                  <number>1</number>
                 </property>
                 <property name="topMargin">
                  <number>1</number>
                 </property>
                 <property name="rightMargin">
                  <number>1</number>
                 </property>
                 <property name="bottomMargin">
                  <number>1</number>
                 </property>
                 <item>
                  <widget class="QFrame" name="fraPlayPause">
                   <property name="frameShape">
                    <enum>QFrame::StyledPanel</enum>
                   </property>
                   <property name="frameShadow">
                    <enum>QFrame::Raised</enum>
                   </property>
                   <layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,9,1">
                    <property name="spacing">
                     <number>0</number>
                    </property>
                    <property name="leftMargin">
                     <number>0</number>
                    </property>
                    <property name="topMargin">
                     <number>0</number>
                    </property>
                    <property name="rightMargin">
                     <number>0</number>
                    </property>
                    <property name="bottomMargin">
                     <number>0</number>
                    </property>
                    <item>
                     <spacer name="vsPlayPause1">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                    <item>
                     <widget class="AspectRatioLabel" name="btnPlayPause">
                      <property name="text">
                       <string/>
                      </property>
                      <property name="pixmap">
                       <pixmap resource="../perinatal__celular_mae.qrc">:/common/res/icone-gravacao-reproduzir.png</pixmap>
                      </property>
                      <property name="scaledContents">
                       <bool>false</bool>
                      </property>
                      <property name="alignment">
                       <set>Qt::AlignCenter</set>
                      </property>
                     </widget>
                    </item>
                    <item>
                     <spacer name="vsPlayPause2">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                   </layout>
                  </widget>
                 </item>
                 <item>
                  <widget class="QFrame" name="fraRecordPause">
                   <property name="frameShape">
                    <enum>QFrame::StyledPanel</enum>
                   </property>
                   <property name="frameShadow">
                    <enum>QFrame::Raised</enum>
                   </property>
                   <layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,9,1">
                    <property name="spacing">
                     <number>0</number>
                    </property>
                    <property name="leftMargin">
                     <number>0</number>
                    </property>
                    <property name="topMargin">
                     <number>0</number>
                    </property>
                    <property name="rightMargin">
                     <number>0</number>
                    </property>
                    <property name="bottomMargin">
                     <number>0</number>
                    </property>
                    <item>
                     <spacer name="vspRecordPause1">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                    <item>
                     <widget class="AspectRatioLabel" name="btnRecordPause">
                      <property name="text">
                       <string/>
                      </property>
                      <property name="pixmap">
                       <pixmap resource="../perinatal__celular_mae.qrc">:/common/res/icone-gracavao-iniciar-gravacao.png</pixmap>
                      </property>
                      <property name="scaledContents">
                       <bool>false</bool>
                      </property>
                      <property name="alignment">
                       <set>Qt::AlignCenter</set>
                      </property>
                     </widget>
                    </item>
                    <item>
                     <spacer name="vspRecordPause2">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                   </layout>
                  </widget>
                 </item>
                 <item>
                  <widget class="QFrame" name="fraStop">
                   <property name="frameShape">
                    <enum>QFrame::StyledPanel</enum>
                   </property>
                   <property name="frameShadow">
                    <enum>QFrame::Raised</enum>
                   </property>
                   <layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,9,1">
                    <property name="spacing">
                     <number>0</number>
                    </property>
                    <property name="leftMargin">
                     <number>0</number>
                    </property>
                    <property name="topMargin">
                     <number>0</number>
                    </property>
                    <property name="rightMargin">
                     <number>0</number>
                    </property>
                    <property name="bottomMargin">
                     <number>0</number>
                    </property>
                    <item>
                     <spacer name="vspStop1">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                    <item>
                     <widget class="AspectRatioLabel" name="btnStop">
                      <property name="text">
                       <string/>
                      </property>
                      <property name="pixmap">
                       <pixmap resource="../perinatal__celular_mae.qrc">:/common/res/icone-gravacao-parar-reproducao.png</pixmap>
                      </property>
                      <property name="scaledContents">
                       <bool>false</bool>
                      </property>
                      <property name="alignment">
                       <set>Qt::AlignCenter</set>
                      </property>
                     </widget>
                    </item>
                    <item>
                     <spacer name="vspStop2">
                      <property name="orientation">
                       <enum>Qt::Vertical</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                       <size>
                        <width>20</width>
                        <height>14</height>
                       </size>
                      </property>
                     </spacer>
                    </item>
                   </layout>
                  </widget>
                 </item>
                </layout>
               </widget>
              </item>
          

          0_1505955307069_003.png

          raven-worx 1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators @canellas last edited by

            @canellas
            where does AspectRatioLabel class come from?
            Nevertheless my best guess would be that the sizes of the image files are very different.
            Mobile displays have higher screen dpi than desktop screens. And i also guess that the AspectRatioLabel implementation does only downscale the images, but not upscale them. Thus you see the images in real size on mobile.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply Reply Quote 0
            • canellas
              canellas last edited by

              I checked again, and both 'play' and 'stop' are 92x92 pixels, and 'record' is 128x128.

              AspectRatioLabel is a QLabel that keeps the aspect ratio of the image, no matter how the window gets bigger or smaller, and with 'click' signal. I can send you the code, if you want.

              I tried with pure QLable and QPushButton, and the result is the same.

              Again, thanks for your time.

              raven-worx 1 Reply Last reply Reply Quote 0
              • raven-worx
                raven-worx Moderators @canellas last edited by

                @canellas
                i think the ApectRatioLabel code would be worth to check next then.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply Reply Quote 0
                • canellas
                  canellas last edited by canellas

                  Well, again, I did it... I had run time code to set the labels (that were buttons), that I forgot to turn off... so there were two different settings for the labels, which led to that mess.

                  Very sorry to take your time with that!

                  Thanks again!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post