#ifndef Mainwindow_h
#define Mainwindow_h
#include <QMainWindow>
Namespace Ui
{
Class MainWindow;
}
Class Mainwindow:public Qmainwindow
{
Q_object
Public
Explicit MainWindow (Qwidget *parent = 0);
~mainwindow ();
Private Slots:
void Buttonslot ();
Protected
void PaintEvent (Qpaintevent *event);
void Mousepressevent (Qmouseevent *event);
Private
Ui::mainwindow *ui;
QString str;
};
#endif//Mainwindow_h
#include "Mainwindow.h"
#include "Ui_mainwindow.h"
#include <QMessageBox>
#include <QLabel>
#include <QPainter>
#include <QMouseEvent>
Mainwindow::mainwindow (Qwidget *parent):
Qmainwindow (parent),
UI (New Ui::mainwindow)
{
UI->SETUPUI (this);
Qobject::connect (Ui->pushbutton,signal (clicked ()), This,slot (Buttonslot ()));//connection signals and slots
}
Mainwindow::~mainwindow ()//destructor
{
Delete UI;
}
void Mainwindow::buttonslot ()
{
Str=ui->lineedit->text ();
Ui->textbrowser->settext (str);
}//put lineedit content in browser
void MainWindow::p aintevent (qpaintevent *event)
{
Q_unused (event);
qpainter painter (this);
Painter.drawtext (170,75, "coordinates-");
}//use painter to write anything.
void Mainwindow::mousepressevent (Qmouseevent *event)
{
Ui->label->settext (QString ("<center>}//coordinates display to label
#include "Mainwindow.h"
#include <QApplication>
int main (int argc, char *argv[])
{
Qapplication A (argc, argv);
MainWindow W;
W.show ();
return A.exec ();
}
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/A6/EC/wKioL1ndyKmCN2l2AAAwEuYn76A104.jpg-wh_500x0-wm_ 3-wmp_4-s_650801848.jpg "title=" tim20171011152619.jpg "alt=" Wkiol1ndykmcn2l2aaaweuyn76a104.jpg-wh_50 "/>
Uploading a picture is really troublesome.
<QT c++> Display coordinates display dialog box contents