I have a dialog class that opens a new window. When I drag the window around the viewing desktop, I want to report the new window geometry (X, Y, width and height) values. I have tried to implement, but get error during compilation that refers to syntax of "connect" statement arguments. Below are dialog source and header; not much to them, but can't seem to get it work.
Also, I can't tell if I've implement the QResizeEvent virtual function to catch the window resize event correctly. Can someone review this problem? I'm not too worried about getting the window position coordinates right now; just want to get the syntax and general design OK. I will continue looking through Qt documentation for answers.
Thanks. Jeff
dialog_xy_plot.cpp:
#include "dialog_xy_plot.h"
#include "ui_dialog_xy_plot.h"
#include "dialog_xy_plot_configure.h"
#include <QDesktopWidget>
#include <QResizeEvent>
#include <QDebug>
Dialog_xy_plot:ialog_xy_plot(QWidget *parent) :
QDialog(parent),
ui(new Ui:ialog_xy_plot)
{
ui->setupUi(this);
connect(this, resizeEvent(QResizeEvent* event), this, SLOT(get_current_window_position()));
QString my_title = "Window Position";
ui->groupBox->setTitle(my_title);
}
void Dialog_xy_plot::get_current_window_position()
{
// get window geometry (x,y, width, height)
qDebug() << "window geometry coorinates are ";
}
void Dialog_xy_plot::resizeEvent(QResizeEvent *event)
{
qDebug() << "in resize ";
QDialog::resizeEvent(event);
}
Dialog_xy_plot::~Dialog_xy_plot()
{
delete ui;
}
dialog_xy_plot.h:
#ifndef DIALOG_XY_PLOT_H
#define DIALOG_XY_PLOT_H
#include <QDialog>
namespace Ui {
class Dialog_xy_plot;
}
class Dialog_xy_plot : public QDialog
{
Q_OBJECT
public:
explicit Dialog_xy_plot(QWidget *parent = 0);
~Dialog_xy_plot();
private slots:
void on_buttonBox_layout_open_accepted();
void get_current_window_position();
private:
Ui:ialog_xy_plot *ui;
protected:
void resizeEvent(QResizeEvent*);
};
#endif // DIALOG_XY_PLOT_H
Bookmarks