Hi all,
I have a layout with multiple widget on a widget, it's a path bar like windows explorer.
When I change folder, I change the layout with the new path who is a layout of button.
The problem is I have bad result when I change folder, it's like a reresh problem, I have the old text on the new text.
Qt Code:
  1. void CContentBrowserPathWidget::UpdatePath()
  2. {
  3. // Get the layout and delete if not NULL.
  4. if( m_Layout != NULL )
  5. delete m_Layout;
  6.  
  7. // Create the layout.
  8. m_Layout = new QHBoxLayout;
  9. m_Layout->setSpacing( 0 );
  10. m_Layout->setMargin( 0 );
  11. setLayout( m_Layout );
  12.  
  13. // Cast the model.
  14. QFileSystemModel* Model = static_cast< QFileSystemModel* >( m_TreeView->model() );
  15.  
  16. // Get the root path.
  17. const QString RootPath = Model->rootPath();
  18.  
  19. // Add the root.
  20. m_Layout->addWidget( new CPathButton( "" ) );
  21.  
  22. // Check if the current index is invalid.
  23. if( m_TreeView->currentIndex().isValid() == false )
  24. return;
  25.  
  26. // Get the current path.
  27. const QString CurrentPath = Model->filePath( m_TreeView->currentIndex() );
  28.  
  29. // Check if the current path is different than the root.
  30. if( CurrentPath != RootPath )
  31. {
  32. QString RightPath = CurrentPath;
  33. RightPath.remove( RootPath + '/' );
  34. const QStringList FolderList = RightPath.split( '/' );
  35. for( int i = 0; i < FolderList.size(); ++i )
  36. m_Layout->addWidget( new CPathButton( FolderList[ i ] ) );
  37. }
  38. }
To copy to clipboard, switch view to plain text mode 
Thanks for the help