QGridLayout
Verfasst: 10. Oktober 2010 16:38
Hallo,
1.
wenn ich Widgets in QGridLayout adde dann wird der Inhalt immer zentriert.
Wie kann ich das ändertn?
Mein Code:
2.
Kann man den Rahmen von QGridLayout anzeigen?
1.
wenn ich Widgets in QGridLayout adde dann wird der Inhalt immer zentriert.
Code: Alles auswählen
ein Element
-----------
| |
| |
| text text |
| |
| |
-----------
zwei Elemente
-----------
| |
| text text |
| |
| text text |
| |
-----------
ich will das aber so
-----------
| text text |
| text text |
| |
| |
| |
-----------
Mein Code:
Code: Alles auswählen
#include "HtmlAttributes.h"
#include <QMessageBox>
HtmlAttributes::HtmlAttributes(QWidget *parent) : QWidget(parent){
layoutGrid = new QGridLayout;
}
void HtmlAttributes::createAttirbutes(QWebElement *web_element, QList<QString> html_attributes){
for(qint32 i=0; i < labels.size(); ++i){
QLabel* label = labels.at(i);
delete label;
labels.removeAt(i);
--i;
}
for(qint32 i=0; i < lineEdits.size(); ++i){
QLineEdit* lineEdit = lineEdits.at(i);
delete lineEdit;
lineEdits.removeAt(i);
--i;
}
for(qint32 i=0; i < html_attributes.size(); ++i){
QString attributeName = html_attributes.at(i);
QString attributeValue = web_element->attribute(attributeName, "-");
QLabel* label = new QLabel(attributeName);
QLineEdit* lineEdit = new QLineEdit(attributeValue);
layoutGrid->setRowMinimumHeight(i, 0);
layoutGrid->addWidget(label, i, 0);
layoutGrid->addWidget(lineEdit, i, 1);
labels.push_back(label);
lineEdits.push_back(lineEdit);
}
setLayout(layoutGrid);
//QMessageBox::information(this, "test", QVariant(layoutGrid->verticalSpacing()).toString(), QMessageBox::Ok);
}
Kann man den Rahmen von QGridLayout anzeigen?