Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Layout works on Desktop, but not on Android cell
Qt 6.11 is out! See what's new in the release blog

Layout works on Desktop, but not on Android cell

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 2 Posters 2.7k Views 2 Watching
  • 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.
  • canellasC Offline
    canellasC Offline
    canellas
    wrote on last edited by
    #1

    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-worxR 1 Reply Last reply
    0
    • canellasC canellas

      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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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
      0
      • canellasC Offline
        canellasC Offline
        canellas
        wrote on last edited by canellas
        #3

        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-worxR 1 Reply Last reply
        0
        • canellasC 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-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @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
          0
          • canellasC Offline
            canellasC Offline
            canellas
            wrote on last edited by
            #5

            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-worxR 1 Reply Last reply
            0
            • canellasC canellas

              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-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @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
              0
              • canellasC Offline
                canellasC Offline
                canellas
                wrote on last edited by canellas
                #7

                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
                0

                • Login

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