How to get text direction in Android and change layout dynamically according to the direction?
Date : March 29 2020, 07:55 AM
Any of those help Solution, was easier that I was thinking :) to JAVA There is Bidi class. This class has getBaseLevel() method which returns 0 if your text is left-to-right otherwise 1 (if right-to-left). @Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if(bidi.getBaseLevel() == 0)
convertView = myInflater.inflate(R.layout.list_add_friends_row, null);
else
convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);
...
Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if(bidi.baseIsLeftToRight())
convertView = myInflater.inflate(R.layout.list_add_friends_row, null);
else
convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);
|
Cleaning a Qt layout and adding other widgets does not work. Ghost widgets stay. Qt bug?
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You are deleting the layout items, but not the widgets that the items used to manage. You must delete the widgets. All of the non-layout items will be deleted automatically when you delete the layout itself. QHBoxLayout* row;
while(!rowLyts_.isEmpty() && (row = rowLyts_.takeAt(0)))
{
QLayoutItem *item;
while ((item = row->takeAt(0))) {
// The item will be deleted when the layout itself is
// destructed. Items such as spacers will return a null
// widget, its deletion is a safe no-op.
delete item->widget();
// We don't handle recursion into sublayouts.
// We check for it so that we won't leak the layout.
Q_ASSERT(!item->layout());
}
delete row;
}
|
PyQt5 grid layout expands for big widgets, but doesn't contract for small widgets
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I think it is impossible for main window because i can't find it in Qt Designer. But you can call mainwindow.adjustSize() on label.changed signal. Update: Sorry, I was wrong. QLabel has no "changed" signal. Other way: def _hide_feedback_label(self):
self.lbl_feedback.setText('')
self.adjustSize() # <--
|
How I can to create gridView with horizontal flickable direction and LeftToRight layout direction?
Tag : qt , By : dyarborough
Date : March 29 2020, 07:55 AM
may help you . I think this number order isnt easy to get without some paging functions. This is closest. Window {
visible: true
width: 800
height:1280
title: qsTr("Hello World")
GridView {
id:grid
width:parent.width*0.95 ; height: parent.height*0.95
verticalLayoutDirection: Grid.TopToBottom
layoutDirection: Qt.LeftToRight
flow: Grid.TopToBottom
anchors.centerIn: parent
model: 11
cellWidth: width/3;
cellHeight: height/3
flickableDirection: Flickable.HorizontalFlick
delegate:Item {
width: grid.cellWidth
height: grid.cellHeight
Rectangle {
color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
width: parent.width*0.75
height: parent.height*0.75
Text {
id: name
text: index.toString()
font.pointSize: 20
}
}
}
}
}
|
Qt: disable layout mirroring in designer?
Tag : qt , By : orlandoferrer
Date : March 29 2020, 07:55 AM
|