In Qt GUI application, I made a dialog containing a table. When I double click a row in the table, I want:
-
a popup window to show up;
-
get points data according to that row from a database;
-
plot those points on the popup window.
I’ve done the fetch function of points data in a database.cpp. But according to the rule, the plotting function has to be in dialog.cpp, in a void Dialog::paintEvent(QPaintEvent *event) function. Can I do the plotting function lineTo() in that database.cpp data fetch function?
You can paint in a
QPixmapfrom anywhere, and pass that pixmap to the popup dialog to be displayed inside aQLabelor painted by thepaintEventfunction.You can also use
QPolygonFwhich has the advantage of being more cleanly scalable.Look at the function
generatePixmapin that article (Qt Quaterly), then useQLabel::setPixmapto assign the pixmap to the label.