Results 1 to 6 of 6

Thread: Usage of QT::UserRole in Qtreewidgetitem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2015
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Usage of QT::UserRole in Qtreewidgetitem

    If it is not the same pointer, how can it be the same object?
    Well I needed 2 pointers to point to the same address. So it's the same object coz they are pointing to the same value. I think that's what you wanted to say.

    But anyhow, I got the solution. I was just writing some extra lines of code for no reason. I did the following :


    Qt Code:
    1. QVariant Headerqv = QVariant("Header");
    2. RootWidget->setData(0, Qt::UserRole, Headerqv);
    3.  
    4. QVariant StrValue = RootWidget->data(0, Qt::UserRole);
    5. QString strval = StrValue.toString();
    6. string str = strval.toStdString();
    To copy to clipboard, switch view to plain text mode 

    But thanks for all the help

    Regards,

  2. #2
    Join Date
    May 2015
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Usage of QT::UserRole in Qtreewidgetitem

    If it is not the same pointer, how can it be the same object?
    I think now I know why you pointed that out. So it seems, widgets are individual objects. I can't use another widget item to point to it and use it values. I thought I could do that.

Similar Threads

  1. Replies: 1
    Last Post: 13th February 2015, 06:42
  2. QFileSystemModel + UserRole
    By NIteLordz in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2015, 17:39
  3. Using Qt::UserRole in the Model/View architecture
    By d_stranz in forum Qt Programming
    Replies: 8
    Last Post: 23rd January 2011, 16:13
  4. Replies: 3
    Last Post: 6th October 2010, 16:11
  5. setting UserRole data in QSqlTableModel
    By orgads in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2008, 09:40

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
  •  
Qt is a trademark of The Qt Company.