aspect-ratio

How to maintain widgets aspect ratio in Qt?

99封情书 提交于 2019-11-26 15:19:49
How is it possible to maintain widgets aspect ratio in Qt and what about centering the widget? Marc Mutz - mmutz You don't have to implement your own layout manager. You can do with inheriting QWidget and reimplementing int QWidget::heightForWidth( int w ) { return w; } to stay square. However, heightForWidth() doesn't work on toplevel windows on X11, since apparently the X11 protocol doesn't support that. As for centering, you can pass Qt::AlignCenter as the third parameter of QBoxLayout::addWidget() or the fifth parameter of QGridLayout::addWidget() . Note: In newer versions of Qt at least,

Set width according to height [duplicate]

白昼怎懂夜的黑 提交于 2019-11-26 14:45:50
问题 This question already has answers here : Setting Element Width Based on Height Via CSS (6 answers) Closed 3 days ago . I saw solution for height depending on width: css height same as width. Or here: https://stackoverflow.com/a/6615994/2256981. But my question is opposite. My element: <body> <div id="square"></div> </body> Style for it: body, html { margin: 0; height: 100%; min-height: 300px; position: relative; } div#square { /* My square. */ height: 75%; /* It's height depends on ancestor's

How to know the image size after applying aspect fit for the image in an UIImageView

此生再无相见时 提交于 2019-11-26 14:23:33
I am loading an image to an imageview with mode as 'Aspect Fit'. I need to know the size to which my image is being scaled to. Please help. Please see @Paul-de-Lange's answer instead of this one I couldn't find anything in an easily accessible variable that had this, so here is the brute force way: - (CGSize) aspectScaledImageSizeForImageView:(UIImageView *)iv image:(UIImage *)im { float x,y; float a,b; x = iv.frame.size.width; y = iv.frame.size.height; a = im.size.width; b = im.size.height; if ( x == a && y == b ) { // image fits exactly, no scaling required // return iv.frame.size; } else if

matplotlib (equal unit length): with &#39;equal&#39; aspect ratio z-axis is not equal to x- and y-

南楼画角 提交于 2019-11-26 14:16:58
When I set up equal aspect ratio for 3d graph the z-axis does not change to 'equal'. So, this: fig = pylab.figure() mesFig = fig.gca(projection='3d', adjustable='box') mesFig.axis('equal') mesFig.plot(xC, yC, zC, 'r.') mesFig.plot(xO, yO, zO, 'b.') pyplot.show() gives me the following: where obviously the unit length of z-axis is not equal to x- and y-units. How can I make the unit length of all three axes equal? All the solutions I could find did not work. Thank you. I believe matplotlib does not yet set correctly equal axis in 3D... But I found a trick some times ago (I don't remember where)

Android Convert Px to Dp (Video Aspect Ratio) [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-26 12:56:55
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: converting pixels to dp in android I\'m trying to convert pixels to dp. What is the formula? Lets convert 640 and 480 into dp. The docs say this The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160) But I don\'t think that is what I need (and I don\'t know how to use this). I guess I just need the forumla. I have the code ready: DisplayMetrics metrics = new DisplayMetrics();

How to deal with different aspect ratios in libGDX?

萝らか妹 提交于 2019-11-26 12:34:46
问题 I have implemented some screens using libGDX that would obviously use the Screen class provided by the libGDX framework. However, the implementation for these screens works only with pre-defined screen sizes. For example, if the sprite was meant for a 640 x 480 size screen (4:3 Aspect ratio), it won\'t work as intended on other screen sizes because the sprites go par the screen boundaries and are not scaled to the screen size at all. Moreover, if simple scaling would have been provided by the

Is there a list of screen resolutions for all Android based phones and tablets? [closed]

ε祈祈猫儿з 提交于 2019-11-26 11:31:24
If not, is there a list of screen resolutions for the most popular Android phones and tablets. Oliver Pearmain (out of date) Spreadsheet of device metrics. SEE ALSO: Device Metrics - Material Design . Screen Sizes . --------------------------- ----- ------------ --------------- ------- ----------- ---------------- --- ---------- Device Inches ResolutionPX Density DPI ResolutionDP AspectRatios SysNavYorN ContentResolutionDP --------------------------- ----- ------------ --------------- ------- ----------- ---------------- --- ---------- Galaxy Y 320 x 240 ldpi 0.75 120 427 x 320 4:3 1.3333 427

How to style a div to be a responsive square? [duplicate]

家住魔仙堡 提交于 2019-11-26 10:08:20
问题 This question already has an answer here: Maintain the aspect ratio of a div with CSS 23 answers I want my div to adapt its height to always equal its width. The width is percental. When the parent\'s width decreases, the box should decrease by keeping its aspect ratio. How to do this is CSS? 回答1: To achieve what you are looking for you can use the viewport-percentage length vw . Here is a quick example I made on jsfiddle. HTML: <div class="square"> <h1>This is a Square</h1> </div> CSS:

How do I keep the aspect ratio on image buttons in android?

拜拜、爱过 提交于 2019-11-26 09:28:32
问题 I have 5 square ImageButtons that I want to have lined up side by side on the bottom of the screen. I have each one set (different id\'s) as: <ImageButton android:id=\"@+id/box1\" android:layout_width=\"fill_parent\" android:layout_height=\"wrap_content\" android:layout_gravity=\"center\" android:adjustViewBounds=\"true\" android:scaleType=\"fitXY\" android:layout_weight=\"1\" android:layout_margin=\"1dp\" /> and I have the background assigned in main java like this: int[] imageIds = new int[

VideoView to match parent height and keep aspect ratio

安稳与你 提交于 2019-11-26 08:16:23
问题 I have a VideoView which is set up like this: <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+id/player\" android:orientation=\"vertical\" android:layout_width=\"fill_parent\" android:layout_height=\"fill_parent\"> <VideoView android:id=\"@+id/video\" android:layout_width=\"wrap_content\" android:layout_height=\"match_parent\" android:layout_centerInParent=\"true\" android:layout_centerVertical=\"true\" /> <ProgressBar android:id=\"@+id/loader\"