void RCharacterWidget::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { lastKey = (event->y() / squareSize) * columns + event->x() / squareSize; #if QT_VERSION < 0x050000 if (QChar(lastKey).category() != QChar::NoCategory) #endif emit characterSelected(QString(QChar(lastKey))); update(); } else QWidget::mousePressEvent(event); }
//! [5] void CharacterWidget::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { lastKey = (event->y()/squareSize)*columns + event->x()/squareSize; if (QChar(lastKey).category() != QChar::Other_NotAssigned) emit characterSelected(QString(QChar(lastKey))); update(); } else QWidget::mousePressEvent(event); }
SearchPinyin::SearchPinyin() { QVBoxLayout* vtLayout = new QVBoxLayout(this); QLabel* pinyinLabel = new QLabel(this); pinyinLabel->setText("Pinyin:"); vtLayout->addWidget(pinyinLabel); pinyin = new QLineEdit(this); vtLayout->addWidget(pinyin); QLabel* disambiguateLabel = new QLabel(this); disambiguateLabel->setText("Disambiguate:"); disambiguateLabel->setObjectName(QString::fromUtf8("label")); vtLayout->addWidget(disambiguateLabel); QScrollArea* candidatesScrollArea = new QScrollArea(this); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(candidatesScrollArea->sizePolicy().hasHeightForWidth()); candidatesScrollArea->setSizePolicy(sizePolicy); candidatesScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); candidatesScrollArea->setWidgetResizable(true); candidates = new RowedList(font(), false, candidatesScrollArea); candidatesScrollArea->setWidget(candidates); candidatesScrollArea->setWidgetResizable(true); vtLayout->addWidget(candidatesScrollArea); stmt = createStatement( "select utf8 from utf8Table join \ kMandarinTable on kMandarinTable.code = utf8Table.code \ where kMandarinTable.kMandarin = ?;"); connect(pinyin, SIGNAL(textEdited(QString)), this, SLOT(searchTermChanged(QString))); connect(candidates, SIGNAL(characterSelected(QString)), this, SLOT(disambiguated(QString))); }