Hi All,
i m facing a very weird problem here. I have created a custom widget derived from QAbstractButton. i m adding five of these widgets to a gridlayout as they should be added.but the none of the widgets show up. never faced such a problem with grid layout. here is the code:
#include "indiciacontainer.h"
#include "indicia.h"
#include <QGridLayout>
IndiciaContainer
::IndiciaContainer(QWidget *parent
){
resize(800, 500);
Indicia *indicia = new Indicia(this);
Indicia *indicia2 = new Indicia(this);
Indicia *indicia3 = new Indicia(this);
Indicia *indicia4 = new Indicia(this);
Indicia *indicia5 = new Indicia(this);
indiciaGroup->addButton(indicia);
indiciaGroup->addButton(indicia2);
indiciaGroup->addButton(indicia3);
indiciaGroup->addButton(indicia4);
indiciaGroup->addButton(indicia5);
indicia->setSvgPicture("d:\\browser.svg");
indicia2->setSvgPicture("d:\\spheres.svg");
indicia3->setSvgPicture("d:\\browser.svg");
indicia4->setSvgPicture("d:\\shapes.svg");
indicia5->setSvgPicture("d:\\bubbles.svg");
grid->setSpacing(5);
grid->addWidget(indicia, 0, 0);
grid->addWidget(indicia2, 0, 1);
grid->addWidget(indicia3, 1, 0);
grid->addWidget(indicia4, 1, 1);
grid->addWidget(indicia5, 2, 0);
QRect rect
= grid
->cellRect
(0,
0);
int x = rect.x();
int y = rect.y();
this->setLayout(grid);
}
#include "indiciacontainer.h"
#include "indicia.h"
#include <QGridLayout>
IndiciaContainer::IndiciaContainer(QWidget *parent)
: QWidget(parent)
{
resize(800, 500);
indiciaGroup = new QButtonGroup(this);
Indicia *indicia = new Indicia(this);
Indicia *indicia2 = new Indicia(this);
Indicia *indicia3 = new Indicia(this);
Indicia *indicia4 = new Indicia(this);
Indicia *indicia5 = new Indicia(this);
indiciaGroup->addButton(indicia);
indiciaGroup->addButton(indicia2);
indiciaGroup->addButton(indicia3);
indiciaGroup->addButton(indicia4);
indiciaGroup->addButton(indicia5);
indicia->setSvgPicture("d:\\browser.svg");
indicia2->setSvgPicture("d:\\spheres.svg");
indicia3->setSvgPicture("d:\\browser.svg");
indicia4->setSvgPicture("d:\\shapes.svg");
indicia5->setSvgPicture("d:\\bubbles.svg");
QGridLayout *grid = new QGridLayout(this);
grid->setSpacing(5);
grid->addWidget(indicia, 0, 0);
grid->addWidget(indicia2, 0, 1);
grid->addWidget(indicia3, 1, 0);
grid->addWidget(indicia4, 1, 1);
grid->addWidget(indicia5, 2, 0);
QRect rect = grid->cellRect(0,0);
int x = rect.x();
int y = rect.y();
this->setLayout(grid);
}
To copy to clipboard, switch view to plain text mode
here is indicia.h :
{
Q_OBJECT
public:
~Indicia();
protected:
private:
Ui::IndiciaChoice ui;
};
class Indicia : public QAbstractButton
{
Q_OBJECT
public:
Indicia(QWidget *parent);
~Indicia();
void setText(QString imageLabel);
void setSvgPicture(QString path);
protected:
void mousePressEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *);
private:
Ui::IndiciaChoice ui;
QSvgWidget *_svgWidget;
};
To copy to clipboard, switch view to plain text mode
any help is appreciated. i need a brisk solution to this
thanks you guys!
Bookmarks