Results 1 to 5 of 5

Thread: update()

  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default update()

    Hello,

    I hope I can make this clear. I am making my own calendar / reminder.
    I use a QTableView and a QStandardItemModel for this. The table also has a delegate and in the delegate a paint event.

    The model is constructed like model = new QStandardItemModel(6, 7, this);
    So it has empty items. The display of the days is done in the paint event which gets a QDate for the left upper day and from there on it displays all the numbers in the calendar.

    This works well for the first time but when I try to display the next month with update(), nothing happens, the paint event does not get called.

    So I do something like:

    Qt Code:
    1. void nextMonth()
    2. {
    3. calculatenextmonthupperleftday();
    4. update();
    5. }
    To copy to clipboard, switch view to plain text mode 

    I think this approach should be possible, how can I generate that paint event anew?

    Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: update()

    Umm, how does the model know which month to represent?
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: update()

    Hi jpn,

    I thought it would be possible that only the paint() in the delegate has to know which month to present / paint.
    The parent of the delegate is the main class which holds a QDate to present the current first date for the current month to be displayed in the calendar.

    I could populate the model with 6 weeks valid QDates, but why, when all that is needed is to display the numbers and some coloring which has to be done by the delegate anyway.

    Something wrong with this logic?

    Quote Originally Posted by jpn View Post
    Umm, how does the model know which month to represent?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: update()

    And where do you store events once you start scheduling stuff in the calendar? What's the purpose of the model in the calendar of yours?
    J-P Nurmi

  5. #5
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: update()

    Appointments are stored in textfiles. When you double click a date you get a little editor which stores it's stuff on disk when ready. It only needs to know the date for the filename. I have functions to convert between QDate and QModelIndex.
    The paint() checks if a file exists and colors the cell accordingly.

    The model's only purpose is to make that tableview work, I don't actualy need the QStandardItems in it. I just need the display and the events like currentchanged() and activated().

    Am I that crazy?

    Quote Originally Posted by jpn View Post
    And where do you store events once you start scheduling stuff in the calendar? What's the purpose of the model in the calendar of yours?
    Last edited by JeanC; 11th February 2008 at 16:28.

Similar Threads

  1. drawForeground update trouble
    By spud in forum Qt Programming
    Replies: 6
    Last Post: 28th March 2011, 00:46
  2. immediate update of QT object
    By db in forum Newbie
    Replies: 3
    Last Post: 14th August 2007, 12:25
  3. why there is no update on maximize? [QTableWidget]
    By macias in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 15:01
  4. How to update statusbar and tooltips
    By aamer4yu in forum Qt Programming
    Replies: 9
    Last Post: 21st December 2006, 12:38
  5. QSlider Update Problem
    By December in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2006, 04:02

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.