Un poco tarde pero recien lo ví, muy bueno @tena.
Saluos.
Saluos.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúconfigure -release -qt-libjpeg -qt-libpng -static
mingw32-make
C:\Qt\2010.05\qt\src\plugins\imageformats\jpeg\jpeg.pro
#ifndef SQL_H
#define SQL_H
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QMessageBox>
#include <QListWidget>
#include <QTreeWidget>
#include <QtGui>
class QTreeWidgetItem;
class cMySql
{
public:
cMySql(){cItem=0;};
bool createConeccion(const QString sServer, const QString sBD, const QString sUser, const QString sPassword);
void closeConeccion();
void listBD(QListWidget *listQuery);
void listTables(QListWidget *listQuery, const QString sBD);
void listRows(QTreeWidget *qtWidget, QTreeWidgetItem *qtrItem, const QString sBD, const QString sTable, QIcon iconItem);
void editResults(const QString sBD, const QString sTable, const QString s1erColumn, const QString sColumn, QString sId, const QString sNewValue);
void MessageBox(const QString sTitle, const QString sMessage);
private:
QSqlDatabase db;
QTreeWidgetItem *cItem;
};
#endif // SQL_H
#include "sql.h"
bool cMySql::createConeccion(const QString sServer, const QString sBD, const QString sUser, const QString sPassword)
{
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName(sServer);
db.setDatabaseName(sBD);
db.setUserName(sUser);
db.setPassword(sPassword);
db.setPort(3306);
if (!db.open()) {
MessageBox("Error al acceder a la Base de Datos",db.lastError().text());
return false;
}
return true;
}
void cMySql::listBD(QListWidget *listQuery)
{
listQuery->clear();
QSqlQuery query;
query.exec("show databases");
while (query.next()) {
listQuery->addItem(query.value(0).toString());
qApp->processEvents(QEventLoop::AllEvents);
}
}
void cMySql::listTables(QListWidget *listQuery, const QString sBD)
{
listQuery->clear();
QSqlQuery query;
query.exec("use " + sBD);
query.exec("SHOW TABLES");
while (query.next()) {
listQuery->addItem(query.value(0).toString());
qApp->processEvents(QEventLoop::AllEvents);
}
}
void cMySql::listRows(QTreeWidget *qtWidget, QTreeWidgetItem *qtrItem, const QString sBD, const QString sTable, QIcon iconItem)
{
qtWidget->clear();
for(int i=0;i<qtrItem->columnCount();i++)
{
qtrItem->setText(i, QApplication::translate("window", (const char *) "", 0, QApplication::UnicodeUTF8));
}
int i =0;
QSqlQuery query;
QSqlQuery query1;
query.exec("use " + sBD);
query.exec("DESCRIBE " + sTable);
while (query.next()) {
qtrItem->setIcon(i, iconItem);
qtrItem->setText(i, QApplication::translate("window", (const char *) query.value(0).toString().toLatin1().data(), 0, QApplication::UnicodeUTF8));
i++;
qApp->processEvents(QEventLoop::AllEvents);
}
qtWidget->setColumnCount(7);
query1.exec("SELECT * FROM " + sTable);
while (query1.next()) {
cItem = new QTreeWidgetItem(qtWidget);
for(int j=0; j<i;j++)
{
const QString setData = query1.value(j).toString();
cItem->setText(j,(const char *)setData.toLatin1().data());
qApp->processEvents(QEventLoop::AllEvents);
}
qApp->processEvents(QEventLoop::AllEvents);
}
}
void cMySql::editResults(QString sBD, QString sTable, QString s1erColumn, QString sColumn, QString sId, QString sNewValue)
{
QSqlQuery query;
query.exec("use " + sBD);
if(query.exec("UPDATE " + sTable + " SET " + sColumn + "='" + sNewValue + "' WHERE " + s1erColumn + "=" + sId))
MessageBox("Edicion Correcta","Se actualizo el valor: " + sNewValue);
else MessageBox("error",query.lastError().text());
}
void cMySql::closeConeccion()
{
if(db.isOpen())db.close();
}
void cMySql::MessageBox(const QString sTitle, const QString sMessage)
{
QMessageBox mBox;
mBox.setWindowTitle(sTitle);
mBox.setText(sTitle);
mBox.setInformativeText( sMessage);
mBox.setStandardButtons(QMessageBox::Ok);
mBox.setDefaultButton(QMessageBox::Ok);
mBox.setIcon(QMessageBox::Information);
mBox.exec();
}
#ifndef WINDOW_H
#define WINDOW_H
#include <QDialog>
#include <QIcon>
#include "sql.h"
class QLineEdit;
class QLabel;
class QPushButton;
class QGroupBox;
class QListWidget;
class QTreeWidget;
class QTreeWidgetItem;
class QTreeWidgetItem;
class QStandardItemModel;
class dWindow: public QDialog
{
Q_OBJECT
public:
dWindow(QWidget *parent = 0);
~dWindow();
void createTreeResult(const QString &sColumn, const int iTotal);
void setDataTreeResult(QTreeWidget *qtWidget, const QString &sData, int iColumna);
protected:
void closeEvent(QCloseEvent *event);
private slots:
void vQueryClicked();
void vQuery(const QString sServer, const QString sBD, const QString sUser, const QString sPassword);
void on_listBD_itemClicked();
void on_listTables_itemClicked();
void on_treeResult_itemClicked();
private:
QLabel *labelUser;
QLabel *labelPassword;
QLabel *labelBD;
QLabel *labelServer;
QLabel *labelResBD;
QLabel *labelTables;
QLabel *labelRows;
QLineEdit *lineUser;
QLineEdit *linePassword;
QLineEdit *lineBD;
QLineEdit *lineServer;
QPushButton *butQuery;
QPushButton *butExit;
QGroupBox *groupBox;
QGroupBox *groupBox1;
QGroupBox *groupBox2;
QListWidget *listBD;
QListWidget *listTables;
QTreeWidget *treeResult;
QTreeWidgetItem *qtrItem;
QIcon icon;
QIcon iconItem;
QTreeWidgetItem *cItem;
QStandardItemModel *model;
cMySql mysql;
};
#endif // WINDOW_H
#include <QtGui>
#include "window.h"
#define MAX_LENGHT 20
dWindow::dWindow(QWidget *parent)
:QDialog(parent)
{
QFont fuente;
fuente.setFamily(QString::fromUtf8("Modern No. 20"));
fuente.setPointSize(14);
fuente.setBold(true);
fuente.setItalic(true);
fuente.setWeight(60);
QFont fuente2;
fuente2.setFamily(QString::fromUtf8("MS Shell Dlg 2"));
fuente2.setPointSize(10);
fuente2.setBold(true);
fuente2.setWeight(50);
QDesktopWidget *d = QApplication::desktop();
int ancho = d->width();
int alto = d->height();
//Añadimos el icono del archivo de recursos
icon.addFile(QString::fromUtf8(":/icos/iconos/find.png"), QSize(), QIcon::Selected, QIcon::On);
iconItem.addFile(QString::fromUtf8(":/icos/iconos/items.png"), QSize(), QIcon::Selected, QIcon::On);
//GROUPBOX PARA LA CONEXION
groupBox = new QGroupBox(this);
groupBox->setObjectName(QString::fromUtf8("gbDatos"));
groupBox->setGeometry(QRect(10, 10, 780, 100)); //X,Y,ANCHO,ALTO
labelUser = new QLabel(tr("USUARIO"),groupBox);
labelUser->setGeometry(QRect(10, 20, 130, 25));
lineUser = new QLineEdit(groupBox);
lineUser->setGeometry(QRect(10, 50, 130, 20));
labelPassword = new QLabel(tr("PASSWORD"),groupBox);
labelPassword->setGeometry(QRect(145, 20, 130, 20));
linePassword = new QLineEdit(groupBox);
linePassword->setEchoMode(QLineEdit::Password);
linePassword->setGeometry(QRect(145, 50, 130, 20));
labelBD = new QLabel(tr("BASE DE DATOS"),groupBox);
labelBD->setGeometry(QRect(280, 20, 170, 25));
lineBD = new QLineEdit(groupBox);
lineBD->setGeometry(QRect(280, 50, 170, 20));
labelServer = new QLabel(tr("SERVIDOR"),groupBox);
labelServer->setGeometry(QRect(455, 20, 130, 25));
lineServer = new QLineEdit(groupBox);
lineServer->setGeometry(QRect(455, 50, 170, 20));
//buttons
butQuery = new QPushButton(tr("Iniciar consulta"),groupBox);
butQuery->setGeometry(QRect(630, 14, 145, 35));
butExit = new QPushButton(tr("Salir"),groupBox);
butExit->setGeometry(QRect(630, 58, 145, 35));
//GROUPBOX PARA LOS RESULTADOS
groupBox1 = new QGroupBox(this);
groupBox1->setObjectName(QString::fromUtf8("gbResultado"));
groupBox1->setGeometry(QRect(10, 115, 780, 105));
labelResBD = new QLabel(tr("Lista Bases de Datos"),groupBox1);
labelResBD->setGeometry(QRect(60, 20, 200, 25));
labelTables = new QLabel(tr("Lista Tablas de la Base de Datos"),groupBox1);
labelTables->setGeometry(QRect(450, 20, 300, 25));
listBD = new QListWidget(groupBox1);
listBD->setGeometry(QRect(10, 45, 370, 50));
listTables = new QListWidget(groupBox1);
listTables->setGeometry(QRect(395, 45, 370, 50));
//GROUPBOX PARA LOS RESULTADOS DE LOS DATOS
groupBox2 = new QGroupBox(this);
groupBox2->setObjectName(QString::fromUtf8("gbDatos"));
groupBox2->setGeometry(QRect(10, 230, 780, 350));
labelRows = new QLabel(tr("Lista datos encontrados en las tablas de la Base de Datos"),groupBox2);
labelRows->setGeometry(QRect(150, 20, 500, 25));
treeResult = new QTreeWidget(groupBox2);
qtrItem = new QTreeWidgetItem();
model = new QStandardItemModel(treeResult);
treeResult->setHeaderItem(qtrItem);
treeResult->setObjectName(QString::fromUtf8("treeResult"));
treeResult->setGeometry(QRect(10, 45, 760, 300));
treeResult->header()->setClickable(true);
QString iniciar = "";
createTreeResult(iniciar,7);
//INCLUYENDO LA FUENTE DE LETRA
groupBox->setFont(fuente);
groupBox1->setFont(fuente);
groupBox2->setFont(fuente);
listBD->setFont(fuente2);
listTables->setFont(fuente2);
treeResult->setFont(fuente2);
//Seteamos el maximo tamaño y numero de caracteres que puenden ingresar
lineUser->setMaxLength(MAX_LENGHT);
linePassword->setMaxLength(MAX_LENGHT);
lineBD->setMaxLength(MAX_LENGHT);
lineServer->setMaxLength(MAX_LENGHT);
connect(butQuery,SIGNAL(clicked()),this,SLOT(vQueryClicked()));
connect(butExit,SIGNAL(clicked()),this,SLOT(close()));
connect(listBD,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(on_listBD_itemClicked()));
connect(listTables,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(on_listTables_itemClicked()));
connect(treeResult,SIGNAL(clicked(QModelIndex)),this,SLOT(on_treeResult_itemClicked()));
groupBox->setTitle(QApplication::translate("Inicio", "REQUISITOS PARA INGRESAR A LA BASE DE DATOS", 0, QApplication::UnicodeUTF8));
groupBox1->setTitle(QApplication::translate("Inicio", "RESULTADOS DEL ESCANEO AL SERVIDOR DE BASE DE DATOS", 0, QApplication::UnicodeUTF8));
groupBox2->setTitle(QApplication::translate("Inicio", "RESULTADOS DE LA CONSULTA A LA TABLA EN LA BASE DE DATOS", 0, QApplication::UnicodeUTF8));
setWindowTitle(tr("MYSQL BROWSER BY 43H4FH44H45H4CH49H56H45H"));
Qt::WindowFlags f = Qt::Window ;
setWindowFlags(f);
setGeometry((ancho)-1100,(alto)-700,800,600);
setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 255);"));
setMaximumSize(800,600);
setMinimumSize(800,600);
setWindowIcon(icon);
}
dWindow::~dWindow()
{
delete labelUser;
delete labelPassword;
delete labelBD;
delete labelServer;
delete labelResBD;
delete labelTables;
delete labelRows;
delete lineUser;
delete linePassword;
delete lineBD;
delete lineServer;
delete butQuery;
delete butExit;
delete groupBox;
delete groupBox1;
delete groupBox2;
delete listBD;
delete listTables;
delete treeResult;
delete qtrItem;
delete cItem;
delete model;
}
void dWindow::vQueryClicked()
{
listTables->clear();
listBD->clear();
treeResult->clear();
if(!lineServer->text().isEmpty() || !lineBD->text().isEmpty() || !lineUser->text().isEmpty()|| !linePassword->text().isEmpty())
{
vQuery(lineServer->text(),lineBD->text(),lineUser->text(),linePassword->text());
}
else mysql.MessageBox("Error en los Datos Ingresados", "Llene todos los datos antes de realizar la conexion");
}
void dWindow::vQuery(const QString sServer, const QString sBD, const QString sUser, const QString sPassword)
{
if(mysql.createConeccion(sServer,sBD,sUser,sPassword))
{
butQuery->setDisabled(true);
lineServer->setDisabled(true);
lineBD->setDisabled(true);
lineUser->setDisabled(true);
linePassword->setDisabled(true);
mysql.listBD(listBD);
}
}
void dWindow::on_listBD_itemClicked()
{
listBD->setDisabled(true);
listTables->setDisabled(true);
treeResult->setDisabled(true);
listTables->clear();
treeResult->clear();
QListWidgetItem *curitem = listBD->currentItem();
QString text = curitem->text();
mysql.listTables(listTables,text);
listBD->setEnabled(true);
listTables->setEnabled(true);
}
void dWindow::on_listTables_itemClicked()
{
listBD->setDisabled(true);
listTables->setDisabled(true);
treeResult->setDisabled(true);
treeResult->clear();
QListWidgetItem *curitem = listBD->currentItem();
QListWidgetItem *curitem2 = listTables->currentItem();
QString text = curitem->text();
listTables->setDisabled(true);
mysql.listRows(treeResult,qtrItem,text,curitem2->text(),iconItem);
listTables->setEnabled(true);
listBD->setEnabled(true);
treeResult->setEnabled(true);
}
void dWindow::on_treeResult_itemClicked()
{
bool ok;
QString edit = QInputDialog::getText(this, tr("¿Desea editar este valor?"),tr("Valor Actual: ") + treeResult->currentIndex().data(Qt::DisplayRole).toString(),QLineEdit::Normal,treeResult->currentIndex().data(2).toString(),&ok,Qt::Dialog);
if (ok)
{
treeResult->currentItem()->setData(treeResult->currentIndex().column(),Qt::EditRole,edit);
mysql.editResults(listBD->currentItem()->text(),
listTables->currentItem()->text(),
qtrItem->data(0,Qt::DisplayRole).toString(),
qtrItem->data(treeResult->currentIndex().column(),Qt::DisplayRole).toString(),
treeResult->currentItem()->data(0,Qt::DisplayRole).toString(),edit);
}
}
void dWindow::createTreeResult(const QString &sColumn, int iTotal)
{
for(int i=0;i<iTotal;i++)
{
qtrItem->setIcon(i, iconItem);
qtrItem->setText(i, QApplication::translate("window", (const char *) sColumn.toLatin1().data(), 0, QApplication::UnicodeUTF8));
}
}
void dWindow::closeEvent(QCloseEvent *event)
{
mysql.closeConeccion();
event->accept();
}
#include <QtGui>
#include "window.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
dWindow *win = new dWindow;
win->show();
return app.exec();
}
configure -release -qt-sql-mysql -l mysql -I D:/MySQL/include -L D:/MySQL/lib/opt -static
mingw32-make
#include <iostream.h>
switch (oper)
{
case 'a':
case 'A':
cout<<"la suma de los numeros es: "<<suma=num1+num2;
break;
Cita de: Amerikano|Cls en 25 Marzo 2011, 00:47 AM
No hay mejor curso que este http://ricardonarvaja.info/WEB/INTRODUCCION%20AL%20CRACKING%20CON%20OLLYDBG%20DESDE%20CERO/