qt


Qt Quick: Putting Repeater and standalone item in GridLayout leads to weird behavior


My code:
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3
Window {
visible: true
width: 640
height: 480
GridLayout {
id: grid
anchors.fill: parent
columns: 6
Repeater {
model: 7
Rectangle {
color: "blue"
Layout.fillWidth: true
Layout.fillHeight: true
}
}
//Rectangle {color: "red"; width: 20; height: 20}
}
}
It shows this:
Which is fine.
But when you uncomment the line containing color: "red", the layout breaks:
Any idea why that is and how to fix it?
I'm not sure if it's causing your issue, because I haven't tested it out, but you should avoid setting the width and height of items that are managed by a Layout:
Note: It is not recommended to have bindings to the x, y, width, or height properties of items in a layout, since this would conflict with the goals of Layout, and can also cause binding loops.
You should use Layout.preferredWidth instead of width, for example.
For more information, see Specifying Preferred Size.

Related Links

QDir and QDirIterator ignore files with non-ASCII filenames
Is there a way to package a dynamic library in the application binary?
Can I decide where a Qaction is added to a Qmenubar
Modifying Qt core components/widgets, best practices? [closed]
How to connect menu click with action in Qt Creator?
How to set output path in a Qt project
How about using SVG(Scalable Vector Graphics) on desktop applications?
Using gSoap in Qt/Windows
Problems with QDialog in Qt
stereo in QT using Open GL
Is anyone using valgrind and Qt?
Compilation of Qt Property Browser
Qt display image in a new window
Newline character into textfile using QFile
How to set QWidget cursor outside the GUI thread
Qt Creator Project Build Error

Categories

HOME
office365
tomcat
apple-push-notifications
opencv-python
paypal-ipn
hdfs
iverilog
celery
gallery
jint
bittorrent
share
amazon-emr
clish
mailmerge
complexity-theory
pygobject
c#-7.0
susy-sass
office-ui-fabric
raml
adminlte
gitkraken
workday
coreldraw
dragula
hevc
macromedia
miniprofiler
amazon-cloudtrail
basic-authentication
guice
vcenter
caesar-cipher
lxml
overwrite
nppexec
subclassing
netstat
cordys-opentext
ng-repeat
sspi
android-n
rdp
microkernel
newtons-method
dagger
oracle-bmcs
line-intersection
htmlspecialchars
kendo-treeview
google-shopping-api
fitbit
tablespace
groovyfx
bbc-micro
unsigned
highlighting
accessibilityservice
gulp-uglify
m4
in-app-billing
self
ora-04091
gql
google-gdk
angular-amd
abstract-factory
erlog
azure-xplat-cli
text-align
camus
dc
inequality
visual-studio-6
ecos
windows-messages
zend-search-lucene
boolean-algebra
windows-taskbar
profiles
meteorite
lsa
facebook-game-groups
yii-booster
lru
donut-chart
sigar
glassfish-esb
vows
rtd
bll
pinax
oracle-pro-c
rational-unified-process
xap
service-factory
error-detection

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App