求助QT inherits的用法

作者&投稿:中叔诚 (若有异议请与网页底部的电邮联系)
QT 错误:C3861: "connect": 找不到标识符~

使用Q_OBJECT宏,需要类继承QObject或其子类。
使用connect的使用可以用QObject::connect(sender,signal,receiver,slot);

The QSound class provides a method to play .wav sound files. More...

Header:#include
qmake: QT += multimedia
Inherits:QObject.
List of all members, including inherited members
Public Types

enumLoop { Infinite }
Public Functions

QSound(const QString & filename, QObject * parent = 0)
~QSound()
QStringfileName() const
boolisFinished() const
intloops() const
intloopsRemaining() const
voidsetLoops(int number)
31 public functions inherited from QObject
Public Slots

voidplay()
voidstop()
1 public slot inherited from QObject
Static Public Members

voidplay(const QString & filename)
10 static public members inherited from QObject
Additional Inherited Members

1 property inherited from QObject
2 signals inherited from QObject
1 public variable inherited from QObject
9 protected functions inherited from QObject
2 protected variables inherited from QObject
Detailed Description

The QSound class provides a method to play .wav sound files.

Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static play() function:

QSound::play("mysounds/bells.wav");
Alternatively, create a QSound object from the sound file first and then call the play() slot:

QSound bells("mysounds/bells.wav");
bells.play();
Once created a QSound object can be queried for its fileName() and total number of loops() (i.e. the number of times the sound will play). The number of repetitions can be altered using the setLoops() function. While playing the sound, the loopsRemaining() function returns the remaining number of repetitions. Use the isFinished() function to determine whether the sound has finished playing.

Sounds played using a QSound object may use more memory than the static play() function, but it may also play more immediately (depending on the underlying platform audio facilities).

If you require finer control over playing sounds, consider the QSoundEffect or QAudioOutput classes.

See also QSoundEffect.

Member Type Documentation

enum QSound::Loop
ConstantValueDescription
QSound::Infinite-1Can be used as a parameter to setLoops() to loop infinitely.
Member Function Documentation

QSound::QSound(const QString & filename, QObject * parent = 0)
Constructs a QSound object from the file specified by the given filename and with the given parent.

See also play().

QSound::~QSound()
Destroys this sound object. If the sound is not finished playing, the stop() function is called before the sound object is destroyed.

See also stop() and isFinished().

QString QSound::fileName() const
Returns the filename associated with this QSound object.

See also QSound().

bool QSound::isFinished() const
Returns true if the sound has finished playing; otherwise returns false.

int QSound::loops() const
Returns the number of times the sound will play. Return value of QSound::Infinite indicates infinite number of loops

See also loopsRemaining() and setLoops().

int QSound::loopsRemaining() const
Returns the remaining number of times the sound will loop (for all positive values this value decreases each time the sound is played). Return value of QSound::Infinite indicates infinite number of loops

See also loops() and isFinished().

[static] void QSound::play(const QString & filename)
Plays the sound stored in the file specified by the given filename.

See also stop(), loopsRemaining(), and isFinished().

[slot] void QSound::play()
This is an overloaded function.

Starts playing the sound specified by this QSound object.

The function returns immediately. Depending on the platform audio facilities, other sounds may stop or be mixed with the new sound. The sound can be played again at any time, possibly mixing or replacing previous plays of the sound.

See also fileName().

void QSound::setLoops(int number)
Sets the sound to repeat the given number of times when it is played.

Note that passing the value QSound::Infinite will cause the sound to loop indefinitely.

See also loops().

[slot] void QSound::stop()
Stops the sound playing.

See also play().



以上内容来之Qt帮助文档

bool QObject::inherits ( const char * lname ) const
如果这个对象是继承clname的类的实例,并且lname继承QObject,那么返回真,否则返回假。
一个类可以被认为继承了它自己。

实例:
QTimer *t = new QTimer; // QTimer继承QObject
t->inherits( "QTimer" ); // 返回TRUE
t->inherits( "QObject" ); // 返回TRUE
t->inherits( "QButton" ); // 返回FALSE

// QScrollBar继承QWidget和QRangeControl
QScrollBar *s = new QScrollBar( 0 );
s->inherits( "QWidget" ); // 返回TRUE
s->inherits( "QRangeControl" ); // 返回FALSE
(注意:QRangeControl不是一个QObject。)
转自qt参考文档


平凉市15948363010: 求助QT inherits的用法 -
言腾派维: bool QObject::inherits ( const char * lname ) const 如果这个对象是继承clname的类的实例,并且lname继承QObject,那么返回真,否则返回假. 一个类可以被认为继承了它自己. 实例: QTimer *t = new QTimer; // QTimer继承QObject t->inherits( ...

平凉市15948363010: Qt网络编程out和in函数的意思的用法 -
言腾派维: 这是声明的QDataStream 的对象,代码自己声明的,并不是预定义的.它是一个流对象,你可以查看QDataStream 的文档,继承自QIODevice,QDataStream out(&block,QIODevice::WriteOnly);这一句声明了out是一个QDataStream 对象,将声...

平凉市15948363010: 初学QT求助一下语法高亮 -
言腾派维: 工具-选项-文本编辑器-显示-高亮显示当前行勾选

平凉市15948363010: linux qt process 和system 的用法 -
言腾派维: QStringList args; args << "-o wav:";//将你后面的那些参数填充..可能 是 | aplay这里有问题,你把这个去掉看行不行.start("mplayer", args);

平凉市15948363010: 求助QT如何实现判断数组中是否存在我想要的元素 -
言腾派维: 可以使用数组的indexOf()方法,如果返回值为-1则说明不存在,如果返回值为大于-1的整数,则说明存在.例如:var arr = [1,2,3]; arr.indexOf(1); // 返回0 arr.indexOf(5); // 返回-1 附:返回值为数组中的最靠前元素在数组的位置

平凉市15948363010: 求助如何用Qt绘制用1位表示黑白的图像 -
言腾派维: 首先你要实现一个可以适时地显示图像的窗体. 要适时地显示图像需要看下QImageReader以及QPainter,QImageReader用来读取图像,QPainter用来绘制图像,但是如果你做的是视频图像采集相关的,可能就用不到这些东西了.

平凉市15948363010: 如何在Qt中使用全局变量,出现无法解析的 -
言腾派维: 很多小伙伴在Qt编程时,不会使用全局变量,其实基本有两种方式来定义使用全局变量,第一种是根据c/c++的extern来进行多文件的使用,第二种方法就是把全局变量放在类中,当做类静态变量来使用,一般来说,第一种方式严重破坏了类的封...

平凉市15948363010: 求助:qt工程中多个ui时如何使用qss -
言腾派维: 简单来说,不要用this->setStyleSheet()父窗体和子窗体如果同时存在一个Widget的控件那么父窗体使用this->setStyleSheet(QSS),那么子窗体的Widget的样式自然也就会被父窗体Widget样式覆盖掉建议是每个控件都不要重名,加上窗体名前缀区分然后QSS里用#【控件名】进行约束,而不是QWidget{}这样来设置样式如果已经开发到了一定程度,修改控件名的代价太大,那就删掉全部的this->setStyleSheet(),然后每个控件单独setStyle(qss)来补救了,虽然烦,但是这是唯一办法

平凉市15948363010: VS08编写QT界面使用QlineEdit的信号问题
言腾派维: 楼上说的不错. 本人用的是qt4.5+vs2008,qt3.8也在同步搞.现在做的就是移植. 首先这里用textEdited这个信号没有问题,当然用textChanged也行.这2个就是参数的含义不同.还有发出的条件有点不一样. 你这里connect的信号名字应该小写...

平凉市15948363010: 请教大神qt调用matlab的方法 -
言腾派维: 动态库的生成1>首先生成目标文件,但是此时要加编译器选项-fpic和链接器选项-shared,gcc -fpic -c add.c gcc -fpic -c sub.c 生成中间文件add.o和sub.o2>其次生成动态库 gcc -shared –o libtiger.so add.o sub.o 生成动态库libtiger.so,libtiger.so就是...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网