PDA

View Full Version : QWidget in a QGraphicsScene ..!!!



salmanmanekia
16th July 2008, 12:36
HI
The below code must show a button in a scene ,but the scene shows a widget in a scene with no button ,it seems as if only a widget is created but widget remains empty...any IDEA !!



class MainScene:public QGraphicsScene
{
public:
QGraphicsProxyWidget *proxy;
Navigation *navigate;
MainScene();

void displayNavigationStatus();
virtual ~MainScene();
};


MainScene::MainScene()
{
navigate = new Navigation;
displayNavigationStatus();
}

void MainScene::displayNavigationStatus()
{
proxy = addWidget(navigate);
}

MainScene::~MainScene()
{
}

class Navigation:public QWidget
{

public:
Navigation();
~Navigation();

private:
QSize buttonIconSize;

QPushButton *backButton ;

void setBackButton();

};

#include "Navigation.h"

Navigation::Navigation()
{
backButton = new QPushButton();
setBackButton();

}
void Navigation::setBackButton()
{
backButton->setIcon(QIcon(BACKBUTTON_DIR_LOCATION));
backButton->setIconSize(buttonIconSize);
backButton->setGeometry(BACK_BUTTON_X,BACK_BUTTON_Y,BUTTON_PAR AM,BUTTON_PARAM);

}

munna
16th July 2008, 12:45
try this


backButton = new QPushButton(this);

salmanmanekia
16th July 2008, 12:48
No difference..still only the grey screen..

salmanmanekia
16th July 2008, 14:09
any help.!!!:confused:

high_flyer
16th July 2008, 14:56
try calling backButton->show();

salmanmanekia
16th July 2008, 15:00
still no difference..!!

high_flyer
16th July 2008, 15:08
The below code must show a button in a scene
Your code however suggest a widget in a scene, *in* which a button is located.
If you try to show this widget normally (not in a scene) does the button show then?

aamer4yu
17th July 2008, 06:07
Agree with high_flyer

Also in

void Navigation::setBackButton()
{
backButton->setIcon(QIcon(BACKBUTTON_DIR_LOCATION));
backButton->setIconSize(buttonIconSize);
backButton->setGeometry(BACK_BUTTON_X,BACK_BUTTON_Y,BUTTON_PAR AM,BUTTON_PARAM);
}

make sure the geometry u set is proper. May be they are not getting initialised properly