Results 1 to 5 of 5

Thread: Rquest for member show() is ambiguous

  1. #1
    Join Date
    Apr 2011
    Posts
    25
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Rquest for member show() is ambiguous

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rquest for member show() is ambiguous

    can post your code?
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Apr 2011
    Posts
    25
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Rquest for member show() is ambiguous

    ok this is my code..

    Qt Code:
    1. class PainterApp : public QDialog,public QCalendarWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit PainterApp(QWidget *parent = 0);
    7. ~PainterApp();
    8.  
    9. private:
    10. Ui::PainterApp *ui;
    11. private slots:
    12. void paintEvent(QPaintEvent *);
    13. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void PainterApp::paintCell(QPainter * painter, const QRect & rect, const QDate & date ) const{
    2.  
    3. QRectF target(30.0, 40.0, 80.0, 60.0);
    4. QRectF source(30.0, 40.0, 70.0, 40.0);
    5. QImage image("C:/QTWork/back-icon.png");
    6.  
    7.  
    8. painter.drawImage(target, image, source);
    9. ui->calendarWidget->paintCell(painter,rect,date.currentDate());
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Rquest for member show() is ambiguous

    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.

  5. #5
    Join Date
    Apr 2011
    Posts
    25
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Rquest for member show() is ambiguous

    ok I am sending my code u please check it..now no error signifies but nothing display in the cell..

    Qt Code:
    1. namespace Ui {
    2. class PainterApp;
    3. }
    4. class MyCalendarWidget : public QCalendarWidget
    5. {
    6. private:
    7. Ui::PainterApp *ui;
    8. protected:
    9. virtual void paintCell(QPainter* painter, const QRectF& rect, const QDate& date);
    10.  
    11. };
    12. class PainterApp : public QDialog
    13. {
    14. Q_OBJECT
    15.  
    16. public:
    17. explicit PainterApp(QWidget *parent = 0);
    18. ~PainterApp();
    19.  
    20. private:
    21. Ui::PainterApp *ui;
    22. private slots:
    23.  
    24. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "painterapp.h"
    2. #include "ui_painterapp.h"
    3.  
    4. PainterApp::PainterApp(QWidget *parent) :
    5. QDialog(parent),
    6. ui(new Ui::PainterApp)
    7. {
    8. ui->setupUi(this);
    9.  
    10. }
    11. void MyCalendarWidget::paintCell(QPainter* painter, const QRectF& rect, const QDate& date)
    12. {
    13.  
    14. rect(30.0, 40.0, 80.0, 60.0);
    15. QImage image("C:/QTWork/back-icon.png");
    16.  
    17.  
    18. painter->drawImage(rect, image, rect);
    19. ui->calendarWidget->paintCell(painter,rect,date.currentDate());
    20. }
    To copy to clipboard, switch view to plain text mode 
    regards
    Anshuman

Similar Threads

  1. ambiguous documentation and behavior of QTcpSocket
    By moviemax in forum General Programming
    Replies: 1
    Last Post: 4th June 2010, 23:11
  2. ambiguous connect()
    By Cruz in forum Qt Programming
    Replies: 2
    Last Post: 27th August 2009, 11:35
  3. Replies: 22
    Last Post: 8th October 2008, 13:54
  4. `QObject' is an ambiguous base of `ClientThread'
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2006, 13:17
  5. Replies: 5
    Last Post: 29th January 2006, 17:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.