Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: Help needed to develop an audio editor

  1. #21
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Help needed to develop an audio editor

    Quote Originally Posted by axeljaeger View Post
    If you show me your code, I will have a look at it.
    Hi,
    I started writing some code.
    The class interface:
    Qt Code:
    1. #ifndef __WAVEFORMDISPLAY_H__
    2. #define __WAVEFORMDISPLAY_H__
    3.  
    4. #include <QWidget>
    5.  
    6. class WaveFormDisplay : public QWidget
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. WaveFormDisplay( QWidget* parent = 0 );
    12.  
    13. protected:
    14. void paintEvent( QPaintEvent* event );
    15. void mousePressEvent(QMouseEvent *event);
    16. void mouseMoveEvent(QMouseEvent *event);
    17. void mouseReleaseEvent(QMouseEvent *event);
    18.  
    19. private:
    20. };
    21.  
    22. #endif //__WAVEFORMDISPLAY_H__
    To copy to clipboard, switch view to plain text mode 

    And the methods:
    Qt Code:
    1. #include "waveformdisplay.h"
    2.  
    3. WaveFormDisplay::WaveFormDisplay( QWidget* parent /* = 0 */ )
    4. {
    5. setPalette( QPalette( QColor( 250, 250, 200 ) ) );
    6. setAutoFillBackground(true);
    7. setWindowTitle( tr("Waveform display") );
    8. resize(500, 200);
    9. }
    10. // Paint event
    11. void WaveFormDisplay::paintEvent( QPaintEvent* event )
    12. {
    13. QLine line( 0, height() / 2.0, width(), height() / 2.0 );
    14. QPen pen( Qt::blue, 1 ); // red solid line, 1 pixels wide
    15.  
    16. QPainter painter( this );
    17. painter.setPen( pen );
    18. painter.setRenderHint( QPainter::Antialiasing );
    19.  
    20. painter.drawLine(line);
    21. }
    22.  
    23. // Mouse press event
    24. void mousePressEvent( QMouseEvent *event )
    25. {
    26. event->accept();
    27. }
    28.  
    29. // Mouse move event
    30. void mouseMoveEvent( QMouseEvent *event )
    31. {
    32. event->accept();
    33. }
    34.  
    35. // Mouse release event
    36. void mouseReleaseEvent( QMouseEvent *event )
    37. {
    38. event->accept();
    39. }
    To copy to clipboard, switch view to plain text mode 

    Do you already have some suggestions? Code is just to start and I already got linker error about mouse event
    Franco Amato

  2. #22
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Help needed to develop an audio editor

    If you would have shown as the error message of the linker, it would be a lot easier to help.

    Anyway, in this simple case I guess you just forgot the WaveFormDisplay:: in the method signature of your implementation to the linker does not know that the three mouse-event-handler belong to your class.

    But also some comments to your code:
    1. Why do you "accept" the mouse-events already?
    2. Although it is good to write documentation, you "document the obvious": http://freeworld.thc.org/root/phun/unmaintain.html
    It's nice to be important but it's more important to be nice.

Similar Threads

  1. Which dll is needed to play the audio files
    By addu in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2009, 23:20

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.