Hi, I'm trying to change grid layout in one of the GroupBoxes, where layout depends on option chosen in Combobox. Here is shortened version of my program. funcion AktualA should change layout in groupBox dane, but this works only with first change of Combobox. Thanks for help
nowywpis.h
#ifndef NOWYWPIS_H
#define NOWYWPIS_H
#include <QWidget>
#include <QGridLayout>
#include <QComboBox>
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
{
Q_OBJECT
public:
private slots:
void AktualA();
void AktualT();
private:
void WyborT();
};
#endif // NOWYWPIS_H
#ifndef NOWYWPIS_H
#define NOWYWPIS_H
#include <QWidget>
#include <QGridLayout>
#include <QComboBox>
QT_BEGIN_NAMESPACE
class QGroupBox;
class QComboBox;
QT_END_NAMESPACE
class NowyWpis : public QWidget
{
Q_OBJECT
public:
NowyWpis(QWidget *parent = 0);
private slots:
void AktualA();
void AktualT();
private:
void WyborT();
QGroupBox *wybort;
QGroupBox *dane;
QComboBox *wybierzt;
};
#endif // NOWYWPIS_H
To copy to clipboard, switch view to plain text mode
nowywpis.cpp
#include <QtGui>
#include "nowywpis.h"
NowyWpis
::NowyWpis(QWidget *parent
) {
WyborT();
}
void NowyWpis::WyborT()
{
…
connect(wybierzt, SIGNAL(currentIndexChanged(int)),
this, SLOT(AktualT()));
connect(wybierzt, SIGNAL(currentIndexChanged(int)),
this, SLOT(AktualA()));
…
grid->addWidget(wybierzt, 0, 0);
wybort->setLayout(grid);
Layout->addWidget(wybort);
Layout->addWidget(dane);
setLayout(Layout);
setWindowTitle(tr("Dodaj nowy wpis"));
resize(800, 600);
}
void NowyWpis::AktualT()
{
wybranyt =(wybierzt->currentText());
}
void NowyWpis::AktualA()
{
…
dane->setLayout(siatka);
}
#include <QtGui>
#include "nowywpis.h"
NowyWpis::NowyWpis(QWidget *parent)
: QWidget(parent)
{
WyborT();
}
void NowyWpis::WyborT()
{
QVBoxLayout *Layout = new QVBoxLayout;
wybort = new QGroupBox(tr("Wybor T"));
dane = new QGroupBox(tr("Dane"));
QGridLayout *grid = new QGridLayout;
wybierzt = new QComboBox;
…
connect(wybierzt, SIGNAL(currentIndexChanged(int)),
this, SLOT(AktualT()));
connect(wybierzt, SIGNAL(currentIndexChanged(int)),
this, SLOT(AktualA()));
…
grid->addWidget(wybierzt, 0, 0);
wybort->setLayout(grid);
Layout->addWidget(wybort);
Layout->addWidget(dane);
setLayout(Layout);
setWindowTitle(tr("Dodaj nowy wpis"));
resize(800, 600);
}
void NowyWpis::AktualT()
{
wybranyt =(wybierzt->currentText());
}
void NowyWpis::AktualA()
{
QGridLayout *siatka = new QGridLayout;
…
dane->setLayout(siatka);
}
To copy to clipboard, switch view to plain text mode
Bookmarks