Gekirou
31st July 2011, 21:41
Hey Guys,
i'm pretty new to QT - actually i'm using QT Jambi. I am stuck solving this problem:
i am building a QWidget which gets it's content from a generated QUiForm. This consists mainly of a QGridLayout, which i want to refill on resize. So what i have to do is either clean the QGridLayout and fill it with my new "icons" or swap the old QGridLayout with a new one.
The Problem is - that i can't do either. It seems that QT Jambi has no method for a QLayout to clear all items. Also my attempts to just swap the old with the new one did not work. It seems, that nor can't i remove the old one, but neither can i swap it with giving it a new layout. It says:"QLayout: Attempting to add QLayout "" to QWidget "Overview", which already has a layout"
Here's my code:
private void rearrangeIcons(QSize size){
int anzahlReihen = size.width()/55;
int anzahlZeilen = size.height()/70;
int gesamt = anzahlReihen * anzahlZeilen;
QGridLayout layout = new QGridLayout(install_base.parent);
int row = 0;
int column = 0;
int current = 0;
for(Entry<String, String> entry : icons.entrySet()){
if(column > anzahlReihen){
column = 0;
row++;
}
layout.addLayout(getLabeledIcon(entry.getKey(), entry.getValue()), row, column, 1, 1);
System.out.println("Adding "+entry.getKey()+ " "+ entry.getValue()+" current Index: "+current+ " to Row "+row+" and Column "+column);
column++;
current++;
}
while(current < gesamt){
if(column > anzahlReihen){
column = 0;
row++;
}
layout.addLayout(new QVBoxLayout(), row, column, 1, 1);
column++;
current++;
}
repaint();
}
}
public QGridLayout gridLayout_2;
public QTreeView treeView;
public QLabel label;
public QWidget parent;
public QScrollArea scrollArea;
public QLayout layout;
public QGridLayout currentLayout;
public Ui_GridView() { super(); }
public void setupUi(QWidget Overview)
{
parent = Overview;
Overview.setObjectName("Overview");
Overview.resize(new QSize(261, 592).expandedTo(Overview.minimumSizeHint()));
layout = new QFormLayout(parent);
}
I would be very happy for every help!
Greetings,
Geki
i'm pretty new to QT - actually i'm using QT Jambi. I am stuck solving this problem:
i am building a QWidget which gets it's content from a generated QUiForm. This consists mainly of a QGridLayout, which i want to refill on resize. So what i have to do is either clean the QGridLayout and fill it with my new "icons" or swap the old QGridLayout with a new one.
The Problem is - that i can't do either. It seems that QT Jambi has no method for a QLayout to clear all items. Also my attempts to just swap the old with the new one did not work. It seems, that nor can't i remove the old one, but neither can i swap it with giving it a new layout. It says:"QLayout: Attempting to add QLayout "" to QWidget "Overview", which already has a layout"
Here's my code:
private void rearrangeIcons(QSize size){
int anzahlReihen = size.width()/55;
int anzahlZeilen = size.height()/70;
int gesamt = anzahlReihen * anzahlZeilen;
QGridLayout layout = new QGridLayout(install_base.parent);
int row = 0;
int column = 0;
int current = 0;
for(Entry<String, String> entry : icons.entrySet()){
if(column > anzahlReihen){
column = 0;
row++;
}
layout.addLayout(getLabeledIcon(entry.getKey(), entry.getValue()), row, column, 1, 1);
System.out.println("Adding "+entry.getKey()+ " "+ entry.getValue()+" current Index: "+current+ " to Row "+row+" and Column "+column);
column++;
current++;
}
while(current < gesamt){
if(column > anzahlReihen){
column = 0;
row++;
}
layout.addLayout(new QVBoxLayout(), row, column, 1, 1);
column++;
current++;
}
repaint();
}
}
public QGridLayout gridLayout_2;
public QTreeView treeView;
public QLabel label;
public QWidget parent;
public QScrollArea scrollArea;
public QLayout layout;
public QGridLayout currentLayout;
public Ui_GridView() { super(); }
public void setupUi(QWidget Overview)
{
parent = Overview;
Overview.setObjectName("Overview");
Overview.resize(new QSize(261, 592).expandedTo(Overview.minimumSizeHint()));
layout = new QFormLayout(parent);
}
I would be very happy for every help!
Greetings,
Geki