Results 1 to 3 of 3

Thread: How to show the drive size in QDirModel

  1. #1

    Post How to show the drive size in QDirModel

    hello everyone,
    I want to show the drive size in QDirModel. I try to rewrite the "SetData" function, but the parameter "value" is a quote, I cant change its value. how can I do it ? thanks.

    note:
    setData: setData(const QModelIndex &index, const QVariant &value, int role)

    磁盘大小.jpg

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show the drive size in QDirModel

    What do you mean by -
    but the parameter "value" is a quote
    The parameter value is const in the arguments and you wont be able to change its value inside the function.

    But you can always pass data to it right...
    Qt Code:
    1. QVariant var = 23;
    2. model->setData(index, var, role);
    To copy to clipboard, switch view to plain text mode 

  3. #3

    Default Re: How to show the drive size in QDirModel

    Thanks your reply.
    But have a problem, the drive size in the second column , the setData have not the parameter "column". I want to show the drive size in the second column and how can I do it. thanks.

    oh, I see. I try .thanks.


    Added after 1 14 minutes:


    I use this:
    model->setData(dirModelIndex,drivesize);

    and in setData function:

    QString driveName = index.data().toString();
    QModelIndex child;
    if (driveName.length() > 1 && driveName.at(1) == QLatin1Char(':'))
    {
    qDebug() << "set drive size";
    child = QDirModel::index(index.row(), 1, index);
    setData(child, value,role);
    emit dataChanged(index, index);
    return true;
    }

    but it not effect. how can I do it? thanks.
    Last edited by kartikzheng; 19th November 2014 at 07:17.

Similar Threads

  1. QDirModel filter drive
    By kartikzheng in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2014, 02:43
  2. Replies: 0
    Last Post: 26th October 2010, 17:59
  3. QDirModel - show directory ".."?
    By jamd in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2009, 19:51
  4. qdirmodel question: show file number of a folder?
    By zl2k in forum Qt Programming
    Replies: 3
    Last Post: 7th November 2008, 07:07
  5. Replies: 2
    Last Post: 11th September 2007, 08:57

Tags for this Thread

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.