Layout works on Desktop, but not on Android cell
-
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!!
-
@canellas
what are the types of the images?
SVGs? PNGs?
What properties did you set on the QLabels? -
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>
-
@canellas
where doesAspectRatioLabel
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. -
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.
-
@canellas
i think the ApectRatioLabel code would be worth to check next then. -