7

フラグ付きのQt::Popupウィンドウ (タイトル バーや閉じるボタンなどがない) があり、タイトル バー以外の領域をドラッグまたはクリックして移動したいと考えています。

Win32 では、ソリューションはWM_NCLBUTTONDOWNである可能性がありますが、私の要件はクロスプラットフォームです。

4

2 に答える 2

18

ウィンドウを手動で移動するには、これを試してください。

void PopupWindow::mousePressEvent(QMouseEvent *event){
    mpos = event->pos();
}

void PopupWindow::mouseMoveEvent(QMouseEvent *event){
    if (event->buttons() & Qt::LeftButton) {
        QPoint diff = event->pos() - mpos;
        QPoint newpos = this->pos() + diff;

        this->move(newpos);
    }
}

QPoint mposそして、どこかで宣言します。

于 2011-04-01T14:12:09.367 に答える
6
if (event->buttons() && Qt::LeftButton) {

この条件はすべてのマウス ボタンに当てはまります

多分あなたはこれを心に留めていました

if (event->buttons() & Qt::LeftButton) {
于 2011-08-31T11:34:51.433 に答える