×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    53

    Setting background Image in Selected cell In CalenderWidget

    i hv tried this code in setting backgroundImage in a particular cell in CalenderWidget but an error occur..cn u please check the error..
    Code:
    void PainterApp::paintEvent(QPaintEvent *)
    {
        QPainter painter(this);
        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,target,QDate::currentDate());
     
         painter.end();
    }
    regards
    Anshuman

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Setting background Image in Selected cell In CalenderWidget

    can you check QImage is not null image ..
    but if you can tell us what error occurs that might us a clue.

  3. #3
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,349

    Re: Setting background Image in Selected cell In CalenderWidget

    I have done something to display background image but not exactly link you.
    you can try this code and replace my bg widget with your calendar widget and let me know what happens
    Code:
    void  SetBackgroundImage()
    {
    //Using QPalette you can set background image as follows.
    QPalette p = palette();
    
    //Load image to QPixmap, Give full path of image
    QPixmap pixmap1(":/images/bg.jpg");
    
    //resize image if it is larger than screen size.
    QDesktopWidget* desktopWidget = QApplication::desktop();
    QRect rect = desktopWidget->availableGeometry();
    QSize size(rect.width() , rect.height());
    //resize as per your requirement..
    QPixmap pixmap(pixmap1.scaled(size));
    
    p.setBrush(QPalette::Background, pixmap);
    setPalette(p);
    }

  4. #4
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: Setting background Image in Selected cell In CalenderWidget

    Seems to be an issue with image path. Make sure the image is there in that path or better load it from resource.

  5. #5
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    53

    Re: Setting background Image in Selected cell In CalenderWidget

    Hello Skumar as per of my code for setting background image in particular cell in calender ..
    {
    QPainter painter(this);
    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,target,QDate::currentDate());

    painter.end();
    }
    The error that comes in the code that is...

    " No matching function for call QCalenderWidget:aintCell(QPainter &,QRect &,QDate)

    candidates are:virtual void QCalenderWidget:aintcell(QPainter *,const QRect&,const QDate)

  6. #6
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Setting background Image in Selected cell In CalenderWidget

    That is compile time error and because of you are passing wrong parameter to function call.

    Try this one...

    Code:
    QDate date = QDate::currentDate();
    ui->calendarWidget->paintCell(&painter,target,date );

Similar Threads

  1. Replies: 3
    Last Post: 2010-07-04, 21:19
  2. Replies: 0
    Last Post: 2008-12-05, 14:31
  3. How to change backcolor and textcolor of the selected cell in CAknGrid?
    By Casper1314 in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-12-05, 13:59
  4. setting selected item in a CAknRadioButtonSettingPage
    By danielos1 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-10-01, 00:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •