Results 1 to 5 of 5

Thread: Status Bar - StatusTipRole

  1. #1
    Join Date
    Mar 2008
    Posts
    29
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Status Bar - StatusTipRole

    Hi,

    I tried to use the StatusBar feature in my Model/View application by selecting the right role in my data() method:

    if (role == Qt::StatusTipRole)
    return QVariant("Hello World");

    but nothing happens :-/ Do I have to activate the status bar in my main window ? Or what is my mistake ?

    Thanks for your help,
    Alex

  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: Status Bar - StatusTipRole

    I am sorry, I didnt get what you want to achieve.

    If you want to display message in the status bar,
    u can use - statusBar()->showMessage() method in the QMainWindow class of ur application.

  3. #3
    Join Date
    Mar 2008
    Posts
    29
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Status Bar - StatusTipRole

    No this is not, what I want to have.

    Qt's Model/View architecture has a data() method, which provides information from the model to the view.
    The data() method has different "roles" which provide different types of data to the view.

    Qt Code:
    1. QVariant SchulungsplanModel::data(const QModelIndex &index, int role) const
    2. {
    3. if (!index.isValid())
    4. {
    5. qDebug("DEBUG: index is not valid:");
    6. return QVariant();
    7. }
    8.  
    9. if (role == Qt::DisplayRole)
    10. return displayRole(index);
    11. else if
    12. (role == Qt::DecorationRole)
    13. return decorationRole(index);
    14. else if
    15. (role == Qt::BackgroundRole)
    16. return backgroundRole(index);
    17. else if
    18. (role == Qt::ToolTipRole)
    19. return toolTipRole(index);
    20. else if
    21. (role == Qt::StatusTipRole)
    22. return QVariant("status");
    23.  
    24. QVariant SchulungsplanModel::displayRole(const QModelIndex &index) const
    25. {
    26. /* if(index.row() == 0 && index.column() == 0 || index.row() == 0 && index.column() == 1)
    27. return QVariant(" hello world");*/
    28.  
    29. return QVariant();
    30. }
    31.  
    32.  
    33. QVariant SchulungsplanModel::decorationRole(const QModelIndex &index) const
    34. {
    35. // return QVariant(QIcon("arrowOpen.png"));
    36. return QVariant();
    37. }
    To copy to clipboard, switch view to plain text mode 

    so the role:
    (role == Qt::StatusTipRole)
    return QVariant("status");
    should return a String to the view, which will be presented automatically in the status bar. As far as I understand, I need not to implement some code for the representation of the status bar, it is done by the MV architecture. Am I right ? The problem is, the statusbar role seem not to work.

  4. #4
    Join Date
    Mar 2008
    Posts
    29
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Status Bar - StatusTipRole

    nobody who can help ?

  5. #5
    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: Status Bar - StatusTipRole

    Which exact version of Qt are you using? Try:
    Qt Code:
    1. view->viewport()->setMouseTracking(true);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. QProcess status
    By mattia in forum Newbie
    Replies: 1
    Last Post: 31st October 2007, 14:15
  2. ld returned 1 exit status.....An unsual error
    By shamik in forum Qt Programming
    Replies: 4
    Last Post: 23rd November 2006, 10:14
  3. Replies: 4
    Last Post: 27th July 2006, 11:13
  4. Replies: 1
    Last Post: 20th July 2006, 09:54
  5. need help with the status bar
    By filmfreak in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2006, 08:34

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.