{+details}: simple button to plot a point, but my slots have no effect on the plot (QwtPlot)
Brought to you by:
rathmann
From: S. A. <sa...@ya...> - 2009-11-16 20:00:35
|
I'm adding more details to the email, cause some of it was dropped earlier . Sorry, like I said I am new to Qwt, but his is a qwt issue since it is a plot that i am working with. Let me expand, part of the original email was not included: The problems are: 1. code in a (public) slot, does not work on the QwtPlot, but if called from the main loop ( or constructor) it works fine. mywidget::mywidget(QWidget *parent): QWidget(parent) { QwtPlot *myplot = new QwtPlot; button = new QPushButton("plot"); // omitting code to put it in a layout connect( button, SIGNAL( clicked() ), myplot, SLOT( myslot() )); } void mywidget::myslot(void) { printf(" myslot() \n"); // code to add data to the plot // does not work curve1->setData( x, y, points) curve1->attach(myplot); myplot->replot(); } When I hit the button, it only prints the printf statement, but does not plot anything. If I take that code and put it in the constructor, then the curve is plotted. 2. code for changing the x-axis scale from Linear to LogScale works only on Mac OS and not in Linux. I've searched for a solution, but have not been lucky. ________________________________ From: Rainer Thaden <RT...@we...> To: S. Aguinaga <sa...@ya...>; List for both Qwt users and developers <qwt...@li...> Sent: Mon, November 16, 2009 10:10:06 AM Subject: Re: simple button to plot a point, but my slots have no effect on the plot (QwtPlot) > I do have the Q_OBJECT macro called from the header file, I just omitted some of the code. > > Because the code that adds the 'curve' and the 'marker or symbol' to the plot do not work > when called from the slot, I think it's a QWT question. I also ran into a problem with the > axis scale (from linear to logscale), it works in the main part of the loop, but if I try changing > it from a slot, it doesn't work on Linux, but works fine in Mac OS (same code!). > > I even tried making the slot public, and that doesn't work either. > I've tried with with qwt 5.1 and 5.2 versions and in Linux, I get the same behavior. > Are you sure, that your slot gets called at all? Did you try to add a qDebug there to write something to the console when the slot get's called? > > I'm trying to create a different class with a built-in slot to do this plotting and call it in my code as: My_Plot *plot = new My_Plot (this); > instead of the way I am doing it now, which is: > QwtPlot *plot = new QwtPlot; > > again, any help or code samples that could get me get over the hump on this > will be appreciated. > What's your question? How to derive a class? class PlotWidget: public QwtPlot { Q_OBJECT public: PlotWidget(QWidget *parent=0); public Q_SLOTS: void mySlot(int myParam); }; That's basic C++ / Qt knowledge and I am afraid this is not the right group for that. Regards, Rainer > Thank you fellows. > > // Sal // Northwestern University ________________________________ From: S. Aguinaga <sa...@ya...> To: Martin Gebert <mar...@al...>; List for both Qwt users and developers <qwt...@li...> Sent: Mon, November 16, 2009 9:40:51 AM Subject: Re: simple button to plot a point, but my slots have no effect on the plot (QwtPlot) Thanks Martin. I do have the Q_OBJECT macro called from the header file, I just omitted some of the code. Because the code that adds the 'curve' and the 'marker or symbol' to the plot do not work when called from the slot, I think it's a QWT question. I also ran into a problem with the axis scale (from linear to logscale), it works in the main part of the loop, but if I try changing it from a slot, it doesn't work on Linux, but works fine in Mac OS (same code!). I even tried making the slot public, and that doesn't work either. I've tried with with qwt 5.1 and 5.2 versions and in Linux, I get the same behavior. I'm still new to Qwt and Qt, so any help you can provide will be greatly appreciated. I'm trying to create a different class with a built-in slot to do this plotting and call it in my code as: My_Plot *plot = new My_Plot (this); instead of the way I am doing it now, which is: QwtPlot *plot = new QwtPlot; again, any help or code samples that could get me get over the hump on this will be appreciated. Thank you fellows. // Sal // Northwestern University ________________________________ From: Martin Gebert <mar...@al...> To: S. Aguinaga <sa...@ya...>; List for both Qwt users and developers <qwt...@li...> Sent: Mon, November 16, 2009 2:27:42 AM Subject: Re: simple button to plot a point, but my slots have no effect on the plot (QwtPlot) This is a general Qt question and not specific to Qwt. However, > harpWestWidget::harpWestWidget() is this class a QObject, and did you insert the Q_OBJECT macro in its declaration? What does the console say when you call the app and connect() is called? Martin |