Results 1 to 14 of 14

Thread: Draw a circle or sequare/rectange by mouse on qwtpolt???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    Implement a custom QwtPlotItem that will represent your rectangle. Use a QwtPlotPicker (or QwtPicker) to allow the user to choose a rectangle. Once the selection is complete, create an instance of your plot item and place it on the plot.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    embeddedmz (26th May 2021)

  3. #2
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    Thank Wysota,

    I used QwtPlotPicker and as i read from the qwtplotpicker a selected signal we be emitted once the selection is done.

    so i connected it like:


    Qt Code:
    1. // [I]this[/I] is the MainWin
    2. connect(plot->picker,SIGNAL(selected(QVector<QPointF>)),this,SLOT(DrawSelection(QVector<QPointF> SelectionPoints)));
    To copy to clipboard, switch view to plain text mode 

    and i have the slot on the mainwindow
    Qt Code:
    1. void MainWin::DrawSelection(QVector<QPointF> SelectionPoints)
    2. {
    3. /// draw the points
    4. }
    To copy to clipboard, switch view to plain text mode 

    but im the single is not emitted
    and when i run it can see the slot saying >>
    Qt Code:
    1. [I]object::connect: No such slot MainWin::DrawSelection(QVector<QPointF> SelectionPoints)[/I
    To copy to clipboard, switch view to plain text mode 
    ]

    so can u please let me know what is the mistake im making ??

    Thanks
    Last edited by jesse_mark; 26th September 2012 at 22:03.

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    I think the message is pretty much self explanatory -- you don't have a slot called "DrawSelection" in your "MainWin" class. Usually this means you either forgot the Q_OBJECT macro or you didn't declare the method as a slot.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #4
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    I do have this method in the MainWin header under

    public slots:
    void DrawSelection( QVector<QPointF> SelectionPoints);


    and i do have other methods using them as slots and i have no problem.

    but what do u exactly mean by Q_OBJECT macro ? I have have Q_OBJECT in header, but to be honest i don't really know exactly what its for .

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    Ah, I read the error message again and I noticed what was wrong. Remove the variable name from the slot signature in the connect() statement.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #6
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    Thanks the error message not there, but the signal is not triggred , after i do my selection the rect and every thing but the signal is not triggered??

    OK i found in the bode example that come with the qwt library

    used a picker and the selected signal

    this way :

    Qt Code:
    1. // mainwindow header
    2. private Q_SLOTS:
    3. void selected(const QPolygon &);
    4.  
    5. //mainwindow cpp
    6. ...
    7. connect(d_picker, SIGNAL(selected(const QPolygon &)),SLOT(selected(const QPolygon &)));
    8. ....
    9. ....
    10. void MainWindow::selected(const QPolygon & )
    11. {
    12.  
    13. qDebug()<<" I got triggred ";
    14. ................
    15. }
    To copy to clipboard, switch view to plain text mode 


    this signal was triggered fine, but why the

    connect(picker, SIGNAL(selected(const QVector<QPointF> &)), SLOT(DrawSelection(const QVector<QPointF> &)));
    was not triggered ???
    Last edited by jesse_mark; 27th September 2012 at 16:09.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Draw a circle or sequare/rectange by mouse on qwtpolt???

    You probably have a Rect picker, not a Point picker machine attached to the picker.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    jesse_mark (27th September 2012)

Similar Threads

  1. how to draw a circle using qml
    By hema in forum Qt Quick
    Replies: 2
    Last Post: 8th August 2016, 12:48
  2. Re: Draw circle in a qframe
    By vinithr in forum Newbie
    Replies: 12
    Last Post: 9th July 2012, 06:52
  3. draw a circle
    By NewLegend in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2010, 16:01
  4. How to draw a special circle pie
    By parnedo in forum Qt Programming
    Replies: 7
    Last Post: 3rd July 2009, 15:25
  5. What is the fastest way to draw a circle ?
    By Vladimir in forum Qt Programming
    Replies: 18
    Last Post: 6th September 2007, 17:26

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.