Illegal call of non-static member function!
-
Hey! I am Burhan
I am working on a periodic table in Qt c++.
The theme is when you click on the button of an element the properties of the respective element appears in the dialog.
Before working on the periodic table and design all buttons i want to test a one first.
While designing the dialog of a button i met some error see this dialog code.
@#include "dialog.h"
#include "ui_dialog.h"
#include<QLabel>
#include <QtGui>
#include <QtCore>Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{ui->setupUi(this); Dialog::information();
}
void information (void)
{
QGridLayout *layout = new QGridLayout;
QLabel *Name = new QLabel("Name");
layout->addWidget(Name,0,0);QLabel *Symbol" = new QLabel("Symbol"); layout->addWidget(Symbol",1,0); QLabel *Atomic= new QLabel("Atomic mass"); layout->addWidget(Atomic,2,0); QLabel *Number= new QLabel("Atomic Number"); layout->addWidget(Number,3,0); Dialog::setLayout(layout);// error: C2352: 'QWidget::setLayout' : illegal call of non-static member function // qwidget.h:546: see declaration of 'QWidget::setLayout' Dialog::show();//error: C2352: 'QWidget::show' : illegal call of non-static member function //qwidget.h:487: see declaration of 'QWidget::show'
}
Dialog::~Dialog()
{
delete ui;
}
@
I want to make a function "information" which contains all the information of element. but when i make a function it shows me some error (mentioned abv)...
Thanks in advance..
Sorry for the bad english. -
Your method information is not implemented as a member function.
Change
@
void information (void)
{
QGridLayout *layout = new QGridLayout;
QLabel *Name = new QLabel("Name");
@to
@
void Dialog :: information (void)
{
QGridLayout *layout = new QGridLayout;
QLabel *Name = new QLabel("Name");
@ -
Ahan i got it :)
Thanks Alot Koahnig! Thanks in tons.I will appreciate, if you can guide me about how to use this function in all dialogs?
means, i want to create a class of this function so that i can use in every dialog because my information method is same for all the dialog.
Thanks again.