×

Discussion Board

Results 1 to 7 of 7

Threaded View

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    10

    Updating size of TableView with delegate on rotation

    I have a custom view delegate to right-align some text and I'm having a problem when the device (Nokia N900) is rotated. The problem seems to be that the QStyleOptionViewItem parameter in the delegate's paint function does not contain the correct rect to represent the size. When the device is rotated, all right-aligned text ends up outside the window and must be scrolled over to bee seen. If the window is opened after the device is first rotated, everything does however work as expected. It seems like the size of the QStyleOptionViewItem's rect member is not updated when the table and the window resizes. As if it is only updated and stored the first time the window is shown.

    Is there a way that I may force the delegate/view to update the size of this rectangle corresponding to the new width/height after rotation? Upon rotation I've tried to call the view's resizeColumnsToContente, updateGeometry and reset()-functions as well as the model's reset() function without any effect.

    The code in question is this:
    Code:
    void DepartureListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                  const QModelIndex &index) const {
        QStyledItemDelegate::paint(painter, option, index);
    
        Departure *e = qVariantValue<Departure *>(index.data());
    
        QFont font = option.font;
        QRect rect = option.rect;
        rect.adjust(10, 10, -20, -7);
    
        painter->save();
    
        painter->drawText(rect, Qt::AlignTop | Qt::AlignLeft, e->lineNumber + " " + e->lineDestination);
        painter->drawText(rect, Qt::AlignTop | Qt::AlignRight, e->arrivalDifference + " min");
    
        painter->setPen(option.palette.mid().color());
        font.setPointSizeF(font.pointSizeF() * 0.70);
        painter->setFont(font);
    
        painter->drawText(rect, Qt::AlignBottom | Qt::AlignLeft, e->arrivalTime);
    
        painter->restore();
    }
    If there are any other ways to right align some of the text using a delegate I would love to hear about those as well
    Last edited by sdragly; 2010-06-02 at 13:46.

Similar Threads

  1. Weird Problem with find box Kern-Exec-3
    By sohilr in forum Symbian C++
    Replies: 7
    Last Post: 2007-12-05, 04:10
  2. KERN-EXEC 3 with CEikEdwin
    By acarrion in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-10-17, 14:43
  3. Audio Input Stream on N80
    By tkaihock in forum Symbian Media (Closed)
    Replies: 9
    Last Post: 2006-06-30, 09:15
  4. Emulator screen size configuration and rotation
    By greatape in forum Symbian C++
    Replies: 0
    Last Post: 2006-03-01, 11:25
  5. User break point error in Grid
    By ag24master in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-08-07, 08:20

Posting Permissions

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