Russian Qt Forum
Май 03, 2024, 17:31 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: QGraphicsScene && mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)  (Прочитано 3180 раз)
nix
Гость
« : Январь 15, 2017, 10:28 »

Не работает перезагрузка функций мыши, на вывод дебага ничего не поступает. Элементарно:
mainwindow.h:
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
...
private:
    Ui::MainWindow *ui;
    QGraphicsScene *scene;
protected:
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
...
mainwindow.cpp:
...
    scene=new QGraphicsScene;
    ui->graphicsView->setScene(scene);
...
void  MainWindow::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent){
    qDebug()<<"mouseMove";
}
...
Записан
Racheengel
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2679


Я работал с дискетам 5.25 :(


Просмотр профиля
« Ответ #1 : Январь 15, 2017, 15:24 »

Включите трекинг событий мыши.

Цитировать
mouseTracking : bool
This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
Access functions:

bool
hasMouseTracking() const
void
setMouseTracking(bool enable)
« Последнее редактирование: Январь 15, 2017, 15:35 от Racheengel » Записан

What is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus.

COVID не волк, в лес не уйдёт
nix
Гость
« Ответ #2 : Январь 15, 2017, 16:53 »

Включите трекинг событий мыши.

Цитировать
mouseTracking : bool
This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
Access functions:

bool
hasMouseTracking() const
void
setMouseTracking(bool enable)
Нет не помогло, пусть даже с нажатой...
Думаю проблема с наследием или как то так, к примеру если использовать QMouseEvent c функции - начинает работать, движение мышкой с нажатой кнопкой рабоает за пределами Viev and Scene, при перемещние мышки и вне Вивера и сцны - функция работает...
Не знаю как правильно реализовать Сцену, чтобы получить возможность перопределить события мышки на ней...
Записан
Racheengel
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2679


Я работал с дискетам 5.25 :(


Просмотр профиля
« Ответ #3 : Январь 15, 2017, 18:12 »

надо от QGraphicsScene  наследовать, а не от MainWindow.
Записан

What is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus.

COVID не волк, в лес не уйдёт
nix
Гость
« Ответ #4 : Январь 15, 2017, 21:15 »

Да, дело было в наследии...
Спасибо.
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.056 секунд. Запросов: 23.