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

Thread: volume control

  1. #21
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    hi
    i only posted the reqired code. this is my full code:
    form1.cpp
    Qt Code:
    1. #include "form1.h"
    2. #include "ui_form1.h"
    3.  
    4. #include "form2.h"
    5.  
    6. #include <QPixmap>
    7. #include <QPalette>
    8. #include <QDesktopWidget>
    9. #include <QRect>
    10. #include <QSize>
    11. #include <QApplication>
    12.  
    13. //#include <QIcon>
    14.  
    15. #include <QMouseEvent>
    16.  
    17.  
    18. #include <phonon/MediaObject>
    19. #include <phonon/AudioOutput>
    20. #include <phonon/VolumeSlider>
    21. #include <QLibrary>
    22. #include <windows.h>
    23.  
    24. Form1::Form1(QWidget *parent) :
    25. QWidget(parent),
    26. ui(new Ui::Form1)
    27. {
    28. ui->setupUi(this);
    29.  
    30. connect(ui->pushButton_24,SIGNAL(clicked()),this,SLOT(showMinimized()));
    31.  
    32. // These three line is used for remove 'window title bar'
    33. this->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
    34. this->setWindowFlags(Qt::CustomizeWindowHint);
    35. this->setWindowFlags(Qt::FramelessWindowHint);
    36.  
    37.  
    38. //this->setWindowFlags(Qt::SplashScreen);
    39.  
    40. //background image using 'pixmap' and 'palette'
    41. this->setFixedSize(270,350);
    42.  
    43. QPixmap pixmap1("E:/workplace/image/two.JPG");
    44. QPalette p = palette();
    45.  
    46. //resize image if it is larger than screen size.
    47. QDesktopWidget* desktopWidget = QApplication::desktop();
    48. QRect rect = desktopWidget->availableGeometry();
    49.  
    50. QSize size(rect.width() , rect.height());
    51. //resize as per your requirement..
    52. //QPixmap pixmap(pixmap1.scaled(size));
    53. QPixmap pixmap(pixmap1.scaled(270,350));
    54.  
    55. p.setBrush(QPalette::Background, pixmap);
    56. setPalette(p);
    57.  
    58. //ui->pushButton->setIcon(QIcon("E:/workplace/image/01.gif"));
    59.  
    60.  
    61. //connect(ui->horizontalSlider,SIGNAL(volumeChanged(Phonon::MediaObject,Phonon::AudioOutput)),
    62. //this,SLOT(setVolumeDecibel(Phonon::MediaObject,Phonon::AudioOutput)));
    63.  
    64.  
    65. QLibrary myLib("C:/Windows/System32/MMSYSTEM.DLL");
    66.  
    67. myLib.load();
    68.  
    69. if (myLib.isLoaded())
    70. {
    71. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(setAudioOutput()));
    72. }
    73.  
    74. //Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    75. //Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    76. //Phonon::createPath(mediaObject, audioOutput);
    77. //mediaObject->setCurrentSource(Phonon::MediaSource("C:/Windows/Suiystem32/MMSYSTEM.DLL"));
    78. //Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
    79. //volumeSlider->setAudioOutput(audioOutput);
    80.  
    81. }
    82.  
    83. Form1::~Form1()
    84. {
    85. delete ui;
    86. }
    87.  
    88. void Form1::one()
    89. {
    90. text1+="1";
    91. //text1+=ui->pushButton->text();
    92. ui->lineEdit->setText(text1);
    93. }
    94.  
    95. void Form1::two()
    96. {
    97. text1+="2";
    98. //text1+=ui->pushButton_4->text();
    99. ui->lineEdit->setText(text1);
    100. }
    101.  
    102. void Form1::three()
    103. {
    104. text1+="3";
    105. //text1+=ui->pushButton_3->text();
    106. ui->lineEdit->setText(text1);
    107. }
    108.  
    109. void Form1::four()
    110. {
    111. text1+="4";
    112. //text1+=ui->pushButton_2->text();
    113. ui->lineEdit->setText(text1);
    114. }
    115.  
    116. void Form1::five()
    117. {
    118. text1+="5";
    119. //text1+=ui->pushButton_5->text();
    120. ui->lineEdit->setText(text1);
    121. }
    122.  
    123. void Form1::six()
    124. {
    125. text1+="6";
    126. //text1+=ui->pushButton_6->text();
    127. ui->lineEdit->setText(text1);
    128. }
    129.  
    130. void Form1::seven()
    131. {
    132. text1+="7";
    133. //text1+=ui->pushButton_7->text();
    134. ui->lineEdit->setText(text1);
    135. }
    136.  
    137. void Form1::eight()
    138. {
    139. text1+="8";
    140. //text1+=ui->pushButton_8->text();
    141. ui->lineEdit->setText(text1);
    142. }
    143.  
    144. void Form1::nine()
    145. {
    146. text1+="9";
    147. //text1+=ui->pushButton_9->text();
    148. ui->lineEdit->setText(text1);
    149. }
    150.  
    151. void Form1::star()
    152. {
    153. text1+="*";
    154. //text1+=ui->pushButton_10->text();
    155. ui->lineEdit->setText(text1);
    156. }
    157.  
    158. void Form1::zero()
    159. text1+="0";
    160. //text1+=ui->pushButton_11->text();
    161. ui->lineEdit->setText(text1);
    162. }
    163.  
    164. void Form1::hash()
    165. {
    166. text1+="#";
    167. //text1+=ui->pushButton_12->text();
    168. ui->lineEdit->setText(text1);
    169. }
    170.  
    171. void Form1::clear()
    172. {
    173. text1 = "";
    174. ui->lineEdit->clear();
    175. }
    176.  
    177. void Form1::showForm2()
    178. {
    179. Form2 *frm2 = new Form2;
    180. frm2->show();
    181. //this->close();
    182. //this->destroy();
    183.  
    184. }
    185.  
    186.  
    187. void Form1::closeSecondWindow()
    188. {
    189. this->close();
    190. }
    191.  
    192. void Form1::mouseMoveEvent(QMouseEvent *event)
    193. {
    194. if (event->buttons() & Qt::LeftButton)
    195. {
    196. move(event->globalPos() - m_dragPosition);
    197. event->accept();
    198. }
    199. }
    200. void Form1::mousePressEvent(QMouseEvent *event)
    201. {
    202. if (event->button() == Qt::LeftButton)
    203. {
    204. m_dragPosition = event->globalPos() - frameGeometry().topLeft();
    205. event->accept();
    206. }
    207. }
    To copy to clipboard, switch view to plain text mode 

    i have another form named form2.this is not matter. i need to access the windows volume control with sliders(horizontal slider)
    Last edited by masuk; 6th February 2011 at 12:35.

  2. #22
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    I don't see any code for accessing windows volume control, and I don't see any definitions for Form2, which is probably why the compiler is complaining.

  3. #23
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    i can't get any solution for control system volume level. as phonon use only for control application volume.i need source code how to control system(xp,vista,linux) volume using slider(horizontal slider).

    thanks

Similar Threads

  1. Sound Volume
    By anafor2004 in forum Qt for Embedded and Mobile
    Replies: 7
    Last Post: 2nd February 2011, 06:03
  2. Replies: 0
    Last Post: 16th December 2009, 09:45
  3. How to get the Volume name from QFileDialog?
    By vishal.chauhan in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2008, 12:28
  4. Volume control for Windows XP
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2007, 06:18
  5. Volume Render
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2006, 10:04

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.