View Full Version : Rquest for member show() is ambiguous
Anshuman
20th April 2011, 13:10
Actually i inherit Qdialog and QCalenderWidget class..now when i build my app the following error ocurrs...can anyone suggest me why is occur..
Error r....
Rquest for member show() is ambiguous //show in main .cpp
with reagrds
Anshuman
mcosta
20th April 2011, 13:30
can post your code?
Anshuman
20th April 2011, 13:36
ok this is my code..
class PainterApp : public QDialog,public QCalendarWidget
{
Q_OBJECT
public:
explicit PainterApp(QWidget *parent = 0);
~PainterApp();
private:
Ui::PainterApp *ui;
private slots:
void paintEvent(QPaintEvent *);
};
void PainterApp::paintCell(QPainter * painter, const QRect & rect, const QDate & date ) const{
QRectF target(30.0, 40.0, 80.0, 60.0);
QRectF source(30.0, 40.0, 70.0, 40.0);
QImage image("C:/QTWork/back-icon.png");
painter.drawImage(target, image, source);
ui->calendarWidget->paintCell(painter,rect,date.currentDate());
}
Berryblue031
20th April 2011, 13:49
It's because of the multiple inheritance. You should avoid multiple inheritance except in the case of pure virtual classes.(interfaces)
Both QDialog and QCalendarWidget have a show function so when PainterApp::show is called it doesn't know whether to call the show from QDialog or from QCalendarWidget.
Redesign your class to only extend QDialog and add a QCalendarWidget to it's ui.
Anshuman
20th April 2011, 14:16
ok I am sending my code u please check it..now no error signifies but nothing display in the cell..
namespace Ui {
class PainterApp;
}
class MyCalendarWidget : public QCalendarWidget
{
private:
Ui::PainterApp *ui;
protected:
virtual void paintCell(QPainter* painter, const QRectF& rect, const QDate& date);
};
class PainterApp : public QDialog
{
Q_OBJECT
public:
explicit PainterApp(QWidget *parent = 0);
~PainterApp();
private:
Ui::PainterApp *ui;
private slots:
};
#include "painterapp.h"
#include "ui_painterapp.h"
PainterApp::PainterApp(QWidget *parent) :
QDialog(parent),
ui(new Ui::PainterApp)
{
ui->setupUi(this);
}
void MyCalendarWidget::paintCell(QPainter* painter, const QRectF& rect, const QDate& date)
{
rect(30.0, 40.0, 80.0, 60.0);
QImage image("C:/QTWork/back-icon.png");
painter->drawImage(rect, image, rect);
ui->calendarWidget->paintCell(painter,rect,date.currentDate());
}
regards
Anshuman
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.