Ignore:
Timestamp:
Dec 22, 2009, 12:42:55 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

tests/widget: Added buttons with shortcuts testcase.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/widget/widget.cpp

    r426 r435  
    252252//      setFocusPolicy(Qt::StrongFocus);
    253253
    254 #if 0
     254#if 1
    255255        MyButton *btn1 = new MyButton(this);
    256         btn1->setText(QLatin1String("Hello 1"));
    257         btn1->setObjectName("Hello 1");
     256        btn1->setText(QLatin1String("&Hello (also Ctrl+H)"));
     257        btn1->setObjectName("Hello");
    258258        btn1->move(20, 20);
     259
     260        connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), btn1),
     261                SIGNAL(activated()), btn1, SLOT(animateClick()));
     262
    259263        MyButton *btn2 = new MyButton(this);
    260         btn2->setText(QLatin1String("Hello 2"));
    261         btn2->setObjectName("Hello 2");
     264        btn2->setText(QString::fromUtf16((const ushort *)L"&\u041f\u0440\u0438\u0432\u0435\u0442 (also Ctrl+\u041f)"));
     265        btn2->setObjectName(QString::fromUtf16((const ushort *)L"\u041f\u0440\u0438\u0432\u0435\u0442"));
    262266        btn2->move(20, 60);
     267
     268        connect(new QShortcut(QKeySequence(Qt::CTRL + 0x041F), btn2),
     269                SIGNAL(activated()), btn2, SLOT(animateClick()));
    263270
    264271//      QComboBox *cb1 = new MyCombo(this);
     
    270277//      cb2->addItem(QLatin1String("Test 4"));
    271278
    272 //      QVBoxLayout *mainLayout = new QVBoxLayout();
    273 //      mainLayout->addWidget(btn1);
    274 //      mainLayout->addWidget(btn2);
     279        QVBoxLayout *mainLayout = new QVBoxLayout();
     280        mainLayout->addWidget(btn1);
     281        mainLayout->addWidget(btn2);
    275282//      mainLayout->addWidget(cb1);
    276283//      mainLayout->addWidget(cb2);
    277284
    278 //      setLayout(mainLayout);
     285        setLayout(mainLayout);
    279286#endif
    280287
     
    306313
    307314    };
     315
     316#if 0
     317    void closeEvent(QCloseEvent *aE)
     318    {
     319        QMessageBox::warning(this, QLatin1String("Close"),
     320                             QLatin1String("Somebody asked us to terminate"));
     321        aE->accept();
     322    }
     323#endif
    308324
    309325#if 0
     
    382398#endif
    383399
    384 #if 0
     400#if 1
    385401    void keyPressEvent(QKeyEvent *aE)
    386402    {
     
    593609#endif
    594610
    595 #if 1
     611#if 0
    596612    //--------------------------------------------------------------------------
    597613    // QSettings test
     
    613629    }
    614630
    615     qDebug() << "Modified Time key in MySoft/MyApp (system & user)";
     631    qWarning() << "Modified Time key in MySoft/MyApp (system & user)";
    616632#endif
    617633
     
    650666#endif
    651667
    652 #if 0
     668#if 1
    653669    QRect r = QApplication::desktop()->availableGeometry();
    654670    MyWidget widget;
     
    679695#endif
    680696
    681 #if 1
     697#if 0
    682698    //--------------------------------------------------------------------------
    683699    // QFileDialog test
Note: See TracChangeset for help on using the changeset viewer.