1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| QTimer *timer = new QTimer;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->listWidget->addItem("coucou");
connect(timer, SIGNAL(timeout()), this, SLOT(monSlot()));
_cpt = 0;
}
void MainWindow::on_listWidget_clicked(const QModelIndex &index)
{
timer->start(QApplication::doubleClickInterval());
_cpt++;
}
void MainWindow::monSlot()
{
if (_cpt == 1)
QMessageBox::information(0, "", "simple");
if (_cpt == 2)
QMessageBox::information(0, "", "double");
_cpt = 0;
timer->stop();
} |
Partager