Let's see, I have achieved getting the path when select an item. But GraphicsView widget is very confusing at the moment.
void FileBrowser
::on_treeView_clicked(QModelIndex index
) {
if(index.isValid())
{
ui->lineEdit->setText(model.filePath(index));
path = lineEdit.Text();
scene.addPixmap(path);
view.show();
}
}
void FileBrowser::on_treeView_clicked(QModelIndex index)
{
QString path;
if(index.isValid())
{
ui->lineEdit->setText(model.filePath(index));
path = lineEdit.Text();
QGraphicsScene scene;
scene.addPixmap(path);
QGraphicsView view(&scene);
view.show();
}
}
To copy to clipboard, switch view to plain text mode
So, I tried to display the item when it is clicked, but I can't get the path from lineEdit.
Added after 18 minutes:
I also got the path added to listView using this:
void FileBrowser::on_addButton_clicked()
{
"Choose music:",
ui->listWidget->addItem(musicPath);;
}
void FileBrowser::on_addButton_clicked()
{
QString musicPath;
path = QFileDialog::getOpenFileName(this,
"Choose music:",
QString::null,
QString::null);
ui->listWidget->addItem(musicPath);;
}
To copy to clipboard, switch view to plain text mode
But it's not actually what I wanted, because I have to browse the file. But all the time Qt said "lineEdit is not declared in this scope". Can I use QLineEdit::copy() or something?
Bookmarks