public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
QString getProjectPath();
QString getCompiler();
QString getColorPlan();
bool getIndent();
bool getAutoComplete();
signals:
void sendData(QString,QString,QString,bool,bool);
QString Dialog::getProjectPath()
{
QString s=ui->lineEdit->text();
return s;
}
QString Dialog::getCompiler()
{
if(ui->radioButton->isChecked())
return QString("VC++ 6.0");
else if(ui->radioButton_2->isChecked())
return QString("VC++ 2012");
else
return QString("g++");
}
QString Dialog::getColorPlan()
{
QListWidgetItem *it =ui->listWidget->currentItem();
if(it==NULL)
return " ";
else
return it->text();
}
bool Dialog::getIndent()
{
if(ui->checkBox->isChecked())
return true;
else
return false;
}
bool Dialog::getAutoComplete()
{
if(ui->checkBox_2->isChecked())
return true;
else
return false;
}
#include <QDialog>
#include <QAction>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QPoint>
namespace Ui {
class Dialog1;
}
class Dialog1 : public QDialog
{
Q_OBJECT
public:
explicit Dialog1(QWidget *parent = 0);
~Dialog1();
protected:
void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
private:
Ui::Dialog1 *ui;
ui(new Ui::Dialog1)
{
ui->setupUi(this);
setCursor(Qt::CrossCursor);
}
Dialog1::~Dialog1()
{
delete ui;
}
void Dialog1::mouseMoveEvent(QMouseEvent *e)
{
ui->label_2->setText("("+QString::number(e->x())+","+QString::number(e->y())+")");
}
void Dialog1::mousePressEvent(QMouseEvent *e)
{
ui->label->move(e->x()-50,e->y()-60);
}
void Dialog1::keyPressEvent(QKeyEvent *e)
{
int x=ui->label->x();
int y=ui->label->y();
// if(e->modifiers() & Qt::ControlModifier)
switch (e->key())
{
case Qt::Key_W:
ui->label->move(x,y-20);
break;
case Qt::Key_S:
ui->label->move(x,y+20);
break;
case Qt::Key_D:
ui->label->move(x+20,y);
break;
case Qt::Key_A:
ui->label->move(x-20,y);
break;
}
QDialog::keyPressEvent(e);
}
void MainWindow::on_actionshow_triggered()
{
Dialog *sh=new Dialog;
if(sh->exec()==QDialog::Accepted)
{
QString s;
s="工程目录:"+sh->getProjectPath()+"\n";
s=s+"编译环境"+sh->getCompiler()+"\n";
s=s+"高亮显示"+sh->getColorPlan()+"\n";
if(sh->getIndent())
s=s+"智能缩进:是\n";
else
s=s+"智能缩进:否\n";
if(sh->getAutoComplete())
s=s+"代码补全:是\n";
else
s=s+"代码补全:否\n";
ui->textEdit->setText(s);
}
}
void MainWindow::on_actionmove_triggered()
{
Dialog1 *ev=new Dialog1;
ev->show();
// Dialog1 ev;
// ev.exec();
}