summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorartoka <arto.katajasalo@digia.com>2011-12-13 12:20:30 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:25:07 (GMT)
commit08e5e81d5ebece3eb3f489d438e2cea5d4adcb4f (patch)
treec775ae5728609a44a2ea2b579a2fb891189f7c4e /doc
parentb10d3383b8dcfafae5adad2f373cc986cc3e66cf (diff)
downloadQt-08e5e81d5ebece3eb3f489d438e2cea5d4adcb4f.zip
Qt-08e5e81d5ebece3eb3f489d438e2cea5d4adcb4f.tar.gz
Qt-08e5e81d5ebece3eb3f489d438e2cea5d4adcb4f.tar.bz2
Various qt documentation fixes (wk 43)
Fixes for bugs: QTBUG-21073, QTBUG-8625, QTBUG-1231, QTBUG-19808, QTBUG-8939, QTBUG-20399, QTBUG-20944, QTBUG-12096, QTBUG-12389, QTBUG-6151, QTBUG-16667, QTBUG-7542, QTBUG-22095, QTBUG-11278 and QTBUG-15653
Diffstat (limited to 'doc')
-rw-r--r--doc/src/porting/qt4-threads.qdoc4
-rw-r--r--doc/src/snippets/audio/audio.pro2
-rw-r--r--doc/src/snippets/audio/main.cpp123
-rw-r--r--doc/src/snippets/code/doc_src_qt4-arthur.cpp9
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp2
-rw-r--r--doc/src/snippets/sqldatabase/sqldatabase.cpp2
6 files changed, 116 insertions, 26 deletions
diff --git a/doc/src/porting/qt4-threads.qdoc b/doc/src/porting/qt4-threads.qdoc
index 87182ea..10cbbc1 100644
--- a/doc/src/porting/qt4-threads.qdoc
+++ b/doc/src/porting/qt4-threads.qdoc
@@ -57,8 +57,8 @@
specific thread. When a signal is emitted, the slot isn't called
immediately; instead, it is invoked when control returns to the
event loop of the thread to which the object belongs. The slot is
- executed in the thread where the receiver object lives. See
- QObject::connect() for details.
+ executed in the thread where the receiver object lives. See
+ \l{signals-and-slots-across-threads} and QObject::connect() for details.
Qt 4 also introduces a new synchronization class: QReadWriteLock.
It is similar to QMutex, except that it distinguishes between
diff --git a/doc/src/snippets/audio/audio.pro b/doc/src/snippets/audio/audio.pro
new file mode 100644
index 0000000..cc02dc8
--- /dev/null
+++ b/doc/src/snippets/audio/audio.pro
@@ -0,0 +1,2 @@
+QT += multimedia
+SOURCES += main.cpp
diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp
index e3244cd..1e26b45 100644
--- a/doc/src/snippets/audio/main.cpp
+++ b/doc/src/snippets/audio/main.cpp
@@ -48,29 +48,71 @@ class Window2 : public QWidget
{
Q_OBJECT
-public slots:
+public:
+
+//![0]
+ void startRecording()
+ {
+ outputFile.setFileName("/tmp/test.raw");
+ outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate );
+
+ QAudioFormat format;
+ // set up the format you want, eg.
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
+ if (!info.isFormatSupported(format)) {
+ qWarning()<<"default format not supported try to use nearest";
+ format = info.nearestFormat(format);
+ }
+
+ audioInput = new QAudioInput(format, this);
+ QTimer::singleShot(3000, this, SLOT(stopRecording()));
+ audioInput->start(&outputFile);
+ // Records audio for 3000ms
+ }
//![0]
+
+//![1]
+ void stopRecording()
+ {
+ audioInput->stop();
+ outputFile.close();
+ delete audioInput;
+ }
+//![1]
+
+public slots:
+//![2]
void stateChanged(QAudio::State newState)
{
switch(newState) {
- case QAudio::StopState:
- if (input->error() != QAudio::NoError) {
- // Error handling
+ case QAudio::StoppedState:
+ if (audioInput->error() != QAudio::NoError) {
+ // Perform error handling
} else {
}
break;
-//![0]
+//![2]
default:
;
}
}
private:
- QAudioInput *input;
-
+//![3]
+ QFile outputFile; // class member.
+ QAudioInput *audioInput; // class member.
+//![3]
};
+
class Window : public QWidget
{
Q_OBJECT
@@ -78,45 +120,86 @@ class Window : public QWidget
public:
Window()
{
- output = new QAudioOutput;
- connect(output, SIGNAL(stateChanged(QAudio::State)),
+ audioOutput = new QAudioOutput;
+ connect(audioOutput, SIGNAL(stateChanged(QAudio::State)),
this, SLOT(stateChanged(QAudio::State)));
}
+public:
+
+//![4]
+ void startPlaying()
+ {
+ inputFile.setFileName("/tmp/test.raw");
+ inputFile.open(QIODevice::ReadOnly);
+
+ QAudioFormat format;
+ // Set up the format, eg.
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
+ if (!info.isFormatSupported(format)) {
+ qWarning()<<"raw audio format not supported by backend, cannot play audio.";
+ return;
+ }
+
+ audioOutput = new QAudioOutput(format, this);
+ connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
+ audioOutput->start(&inputFile);
+ }
+//![4]
+
+//![5]
+ void finishedPlaying(QAudio::State state)
+ {
+ if(state == QAudio::IdleState) {
+ audioOutput->stop();
+ inputFile.close();
+ delete audioOutput;
+ }
+ }
+//![5]
+
private:
+
void setupFormat()
{
-//![1]
+//![6]
QAudioFormat format;
format.setFrequency(44100);
-//![1]
+//![6]
format.setChannels(2);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
-//![2]
+//![7]
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format))
format = info.nearestFormat(format);
-//![2]
+//![7]
}
public slots:
-//![3]
+//![8]
void stateChanged(QAudio::State newState)
{
switch (newState) {
- case QAudio::StopState:
- if (output->error() != QAudio::NoError) {
+ case QAudio::StoppedState:
+ if (audioOutput->error() != QAudio::NoError) {
// Perform error handling
} else {
// Normal stop
}
break;
-//![3]
+//![8]
// Handle
case QAudio::ActiveState:
@@ -129,7 +212,11 @@ public slots:
}
private:
- QAudioOutput *output;
+
+//![9]
+ QFile inputFile; // class member.
+ QAudioOutput *audioOutput; // class member.
+//![9]
};
int main(int argv, char **args)
diff --git a/doc/src/snippets/code/doc_src_qt4-arthur.cpp b/doc/src/snippets/code/doc_src_qt4-arthur.cpp
index 6268309..e525269 100644
--- a/doc/src/snippets/code/doc_src_qt4-arthur.cpp
+++ b/doc/src/snippets/code/doc_src_qt4-arthur.cpp
@@ -74,7 +74,7 @@ painter.drawEllipse(0, 0, 100, 100);
painter.setBrush(QColor(255, 0, 0, 127));
painter.drawRect(0, 0, width()/2, height());
-// Specify semi-transparend blue
+// Specify semi-transparent blue
painter.setBrush(QColor(0, 0, 255, 127));
painter.drawRect(0, 0, width(), height()/2);
//! [3]
@@ -86,15 +86,16 @@ painter.drawLine(0, 0, width()/2, height());
// One line with anti-aliasing
painter.setRenderHint(QPainter::Antialiasing);
-painter.drawLine(width()/2, 0, width()/2, height());
+painter.drawLine(width()/2, 0, width(), height());
//! [4]
//! [5]
QPainterPath path;
path.addRect(20, 20, 60, 60);
-path.addBezier(0, 0, 99, 0, 50, 50, 99, 99);
-path.addBezier(99, 99, 0, 99, 50, 50, 0, 0);
+path.moveTo(0, 0);
+path.cubicTo(99, 0, 50, 50, 99, 99);
+path.cubicTo(0, 99, 50, 50, 0, 0);
painter.drawPath(path);
//! [5]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
index 35e6feb..1e78ed0 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -73,7 +73,7 @@ MyStruct s2 = var.value<MyStruct>();
//! [3]
int id = QMetaType::type("MyClass");
-if (id == 0) {
+if (id != 0) {
void *myClassPtr = QMetaType::construct(id);
...
QMetaType::destroy(id, myClassPtr);
diff --git a/doc/src/snippets/sqldatabase/sqldatabase.cpp b/doc/src/snippets/sqldatabase/sqldatabase.cpp
index 4f428c7..1f20884 100644
--- a/doc/src/snippets/sqldatabase/sqldatabase.cpp
+++ b/doc/src/snippets/sqldatabase/sqldatabase.cpp
@@ -284,12 +284,12 @@ void QSqlTableModel_snippets()
model->setTable("employee");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
- model->removeColumn(0); // don't show the ID
model->setHeaderData(0, Qt::Horizontal, tr("Name"));
model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
QTableView *view = new QTableView;
view->setModel(model);
+ view->hideColumn(0); // don't show the ID
view->show();
//! [24]