Results 1 to 2 of 2

Thread: Getting access to SeekSlider from another class

  1. #1
    Join Date
    Apr 2010
    Location
    Rzeszów \ Poland
    Posts
    26
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Getting access to SeekSlider from another class

    Hello.
    I'm writing a litte music-player based on Qt and Phonon.
    Im using a double-linked list (writed by myself) to storage a data and information. First class, File, storage information about opened files:
    Qt Code:
    1. #include "file.h"
    2.  
    3. //Phonon::MediaObject *mediaObject;
    4. //Phonon::AudioOutput *audioOutput;
    5.  
    6. File::File()
    7. {
    8. this->next = 0;
    9. this->prev = 0;
    10. this->path_to_file = "";
    11. this->fileName = "";
    12. this->title = "";
    13. }
    14.  
    15. void File::setPath(QString path)
    16. {
    17. this->path_to_file = path;
    18. }
    19.  
    20. QString File::returnPath()
    21. {
    22. return this->path_to_file;
    23. }
    24.  
    25. void File::playFile()
    26. {
    27. this->mediaObject = new Phonon::MediaObject(this);
    28. this->mediaObject->setCurrentSource(this->returnPath());
    29. this->audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
    30. Phonon::Path path = Phonon::createPath(this->mediaObject,this->audioOutput);
    31. this->mediaObject->play();
    32. }
    33.  
    34. void File::stopFile()
    35. {
    36. this->mediaObject->stop();
    37. }
    38.  
    39.  
    40. void File::setFileName(QString path)
    41. {
    42. int n = 0; QString temp = "";
    43. for(int i=0;i<path.length();i++)
    44. {
    45. if (path[i] == '/')
    46. n = i+1;
    47. }
    48. for(int i=n;i<path.length();i++)
    49. temp.append(path[i]);
    50. this->fileName = temp;
    51. }
    52.  
    53. QString File::returnFileName()
    54. {
    55. return this->fileName;
    56. }
    57.  
    58. File *File::Copy(File &f)
    59. {
    60. File * temp = new File();
    61. temp->setFileName(f.returnFileName());
    62. temp->setPath(f.returnPath());
    63. temp->next = f.next;
    64. temp->prev = f.prev;
    65. return temp;
    66. }
    To copy to clipboard, switch view to plain text mode 

    And second class it's double-linked list.

    I want to make a seekslider, but I have a little problem. I'm using mediaObject not in MainWindow, but in another class.
    Something like this doesnt work (in MainWindow):
    Qt Code:
    1. ss->setMediaObject(playlist->ReturnX(i)->mediaObject);
    To copy to clipboard, switch view to plain text mode 
    I also can't make a function i File class that return a mediaObject.

    Someone can help me how to resolve this problem??

  2. #2
    Join Date
    Apr 2010
    Location
    Rzeszów \ Poland
    Posts
    26
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Getting access to SeekSlider from another class

    The best solution would be a function retunred mediaObject from File class. But I have problem with do this.
    If I have a mediaObject as global variable or as public variable I can't do it.

    Someone can help me with this problem?

Similar Threads

  1. How to access the UI from another class ?
    By fitzy in forum Qt Programming
    Replies: 22
    Last Post: 20th July 2016, 15:21
  2. Access from other class
    By champ in forum Newbie
    Replies: 2
    Last Post: 12th June 2010, 17:04
  3. Replies: 4
    Last Post: 29th May 2010, 13:56
  4. ui class access problem
    By marct in forum Newbie
    Replies: 4
    Last Post: 25th February 2010, 01:32
  5. Replies: 5
    Last Post: 14th July 2006, 23:42

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.