Results 1 to 7 of 7

Thread: Qwt zoom vs. Qt move

  1. #1
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qwt zoom vs. Qt move

    I have a QMainWindow application A which opens another QMainWindow application B. The second application (B) has a widget that displays a QwtPlot with a QwtPlotZoomer.
    I can run application B independently or open it as a window through application A.

    When I run B independently, it works well: I can zoom in and out of the plot.
    When I run A and create B as a child, I get two signals - 1. the original zoom 2. moving of the window inside the central widget.

    I'm not interested in moving the window when I'm in the QwtPlot widget (only zooming).
    How can I disable the second signal for only that widget? (As I still want to be able to move the window when outside the plot widget)
    I didn't connect the move signal so I assume it's done by default?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    Hard to understand, what you mean by "signal", but obviously it is not: http://doc.trolltech.com/4.3/signalsandslots.html.
    Do you mean, that in situation B your plot widget gets moved around, when you drag the left mouse button on the plot canvas ?

    Uwe

  3. #3
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    I'll try to explain again:
    I open a window in the central area of my QMainWindow application. This window contains a widget that displays a plot. When I try to zoom by dragging the left mouse button on the plot canvas, the whole window (not just the plot widget) moves as well (inside the QMainWindow central area).
    So the zoom functionality works fine but in addition the window moves (which makes it difficult to zoom).

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    Quote Originally Posted by user View Post
    I open a window in the central area of my QMainWindow application.
    What do you mean by open - guess it is not QMainWindow::setCentralWidget ?
    Sounds a bit like you are using QMdiArea/QMdiSubWindow.

    Uwe

  5. #5
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    I have:

    Qt Code:
    1. class MyMainWindow : public QMainWindow
    2.  
    3. MyMainWindow::MyMainWindow() : QMainWindow(0,0)
    4. {
    5. ...
    6. workspace_ = new QWorkspace();
    7. setCentralWidget(workspace_);
    8. ...
    9. }
    10.  
    11. void MyMainWindow::createChild()
    12. {
    13. ...
    14. child = new MyTool();
    15. workspace_->addWindow(child);
    16. child->show()
    17. }
    18.  
    19.  
    20. class MyTool : public QMainWindow
    21.  
    22. MyTool::MyTool(QWidget * parent) : QMainWindow(parent,0)
    23. {
    24. ...
    25. scrollArea_ = new QScrollArea;
    26. setCentralWidget(scrollArea_);
    27. scrollArea_->setWidgetResizable ( true );
    28. scrollArea_->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    29. scrollArea_->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    30. scrollAreaGridLayout_ = new QGridLayout(scrollArea_);
    31. scrollAreaWidget_ = new QWidget();
    32. scrollAreaGridLayout_->addWidget(scrollAreaWidget_, 0, 1, 1, 1);
    33. scrollArea_->setWidget(scrollAreaWidget_);
    34. tabWidget_ = new QTabWidget();
    35. scrollAreaGridLayout2_ = new QGridLayout(scrollAreaWidget_);
    36. scrollAreaGridLayout2_->addWidget(tabWidget_, 0, 1, 1, 1);
    37. tabWidget_->setEnabled(true);
    38. ...
    39. }
    To copy to clipboard, switch view to plain text mode 
    The tabWidget_ will eventually display Profile - a class that contains a plot:
    Qt Code:
    1. class Profile : public QWidget
    2.  
    3. Profile::Profile(QWidget * parent) : QWidget(parent)
    4. {
    5. ...
    6. graphicDisplay = new ProfileGraphicDisplay(this);
    7. ...
    8. }
    9.  
    10. class ProfileGraphicDisplay : public QwtPlot
    11.  
    12. ProfileGraphicDisplay ::ProfileGraphicDisplay (QWidget *parent) : QwtPlot(parent)
    13. {
    14. ...
    15. canvas1_ = canvas();
    16. canvas1_->installEventFilter(this);
    17. canvas1_->setCursor(Qt::PointingHandCursor);
    18. canvas1_->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
    19. canvas1_->setFocus();
    20. canvas1Picker_ = new QwtPlotPicker( canvas1_ );
    21. canvas1Picker_->setTrackerPen(QColor(Qt::black));
    22. canvas1Picker_->setSelectionFlags( QwtPicker::PointSelection | QwtPicker::DragSelection );
    23. canvas1Picker_->setTrackerMode( QwtPicker::AlwaysOff );
    24. connect( canvas1Picker_, SIGNAL( selected( const QwtDoublePoint & ) ), this, SLOT( pointSelected( const QwtDoublePoint & ) ) );
    25. canvas1Zoomer_ = new QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas1_ );
    26. canvas1Zoomer_->setSelectionFlags( QwtPicker::DragSelection );
    27. canvas1Zoomer_->setTrackerMode(QwtPicker::ActiveOnly);
    28. curve1_ = new QwtPlotCurve();
    29. curve1_->setData( xProfile_, yProfile_ );
    30. ...
    31. }
    To copy to clipboard, switch view to plain text mode 

    So, When I use canvas1Zoomer_ to zoom in the ProfileGraphicDisplay area, MyTool window moves inside workspace_.

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    AFAIR, this can be fixed by setting the Qt::WA_NoMousePropagation flag. What happens, when you add the following line to MyMainWindow::createChild:

    child->setAttribute(Qt::WA_NoMousePropagation, false);

    Uwe

  7. The following user says thank you to Uwe for this useful post:

    user (14th November 2007)

  8. #7
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt zoom vs. Qt move

    child->setAttribute(Qt::WA_NoMousePropagation, true);

    That worked.
    Thank you Uwe.

Similar Threads

  1. QWT introduction
    By nitriles in forum Qwt
    Replies: 4
    Last Post: 28th September 2007, 10:48
  2. How to upgrade Qwt 5.0.1 to Qwt 5.0.2
    By luffy27 in forum Qwt
    Replies: 1
    Last Post: 15th July 2007, 19:55
  3. Zoom Options
    By Kapil in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 11:19
  4. use interesting QWT Library with QT3.X
    By raphaelf in forum Qwt
    Replies: 2
    Last Post: 23rd January 2006, 11:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.