Displaying only *.txt files in open file dialog

I have written the below code to filter only .txt files.
@
QString filename = QFileDialog::getOpenFileName(this,tr("Open Document"),QDir::currentPath(),tr("text files (*.txt);") );
@
But for above code it is not filtering and displaying *.txt files.

If i write following code it is showing .txt files but also it will display all files when user selects All files option.
@
QString filename = QFileDialog::getOpenFileName(this,tr("Open Document"),QDir::currentPath(),tr("text files (.txt);;All files*.*)") );
@
So how to display only *.txt files?