QString file_name = ...;QPushButton * button = new QPushButton( ... );button->setProperty( "_file_name", file_name );connect( button, SIGNAL(clicked()), SLOT(button_clicked()) );...void MyClass::button_clicked(){ QString file_name = sender()->property( "_file_name" );}
QString file_name = ...;MyHandler * handler = new MyHandler;handler->file_name = file_name;QPushButton * button = new QPushButton( ... );connect( button, SIGNAL(clicked()), handler, SLOT(button_clicked()) );
const char* path = "yourdir";QDir dir(path);dir.setFilter(QDir::Files);QStringList fileList = dir.entryList();QVBoxLayout *lt = new QVBoxLayout(this);foreach(QString fileName, fileList) { QPushButton *btn = new QPushButton(fileName, this); connect(btn, SIGNAL(clicked()), this, SLOT(onClick())); lt->addWidget(btn);}