void F_addPc::add_pc_to_db(){ QString names = FMain::trWd_tree->currentItem()->text(0);....
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QtGui/QMainWindow>#include <QObject>#include <QWidget>#include "ui_server.h"#include "ui_add_new_pc.h"// Главная формаclass FMain : public QMainWindow, Ui::FMain{ Q_OBJECTpublic: FMain(QMainWindow* p=0) : QMainWindow(p) { setupUi(this); connect(pushButton, SIGNAL(clicked()), this, SLOT(add_group_win())); connect(trWd_tree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(menu_sub_group(const QPoint &))); }private slots: void on_actionExit_triggered();public slots: void add_group(QString gr_name); void add_group_win(); void menu_sub_group(const QPoint &); void add_sub_group(); static bool createConnection();};// Форма в которой я хочу узнать текст элементаclass F_addPc : public QWidget, private Ui::F_addPc{ Q_OBJECT public: F_addPc(QWidget *parent = 0) { setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(add_pc_to_db())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); } public slots: void add_pc_to_db();};#endif // MAINWINDOW_H
#include <QtCore>#include "mainwindow.h"#include "ui_server.h"#include "ui_add_new_pc.h"#include <qinputdialog.h>#include <QtSql>#include <QMessageBox>// show popUp Menu in TreeViewvoid FMain::menu_sub_group(const QPoint &pos){ QTreeWidgetItem *item = trWd_tree->itemAt(pos); if (!item) return; QString name = trWd_tree->currentItem()->text(0); QMenu menu(tr("Context menu"), this); // menu if right click Group if (!trWd_tree->currentItem()->parent()) { menu.addAction(tr("Add PC to Group"), this, SLOT(add_sub_group())); menu.addAction(tr("Rename Group"), this, SLOT(add_sub_group())); } //menu if right click on PC name else { menu.addAction(tr("Move PC to another group"), this, SLOT(add_sub_group())); menu.addAction(tr("Delete PC"), this, SLOT(add_sub_group())); } menu.exec(trWd_tree->viewport()->mapToGlobal(pos));}void FMain::add_sub_group(){ // в этом месте всё работает, то есть names равен названию элемента QString names = trWd_tree->currentItem()->text(0); // show Window to ad new PC F_addPc *nF_addPc = new F_addPc(this); nF_addPc->setAttribute(Qt::WA_DeleteOnClose); nF_addPc->show();}void F_addPc::add_pc_to_db(){ QString names = FMain::trWd_tree->currentItem()->text(0); QString pc_name, pc_ip, pc_comment, gr_name; int old_id; pc_name = le_pcName->text(); pc_ip = le_ipAddr->text(); pc_comment = le_comment->text(); //gr_name = FMain:: FMain::createConnection(); }
TreeWidget* get_trWd_tree(void) { return trWd_tree; }
class F_addPc : public QWidget, private Ui::F_addPc{ Q_OBJECT public: F_addPc(const QString & parentName, QWidget *parent = 0) : QWidget(parent), mParentName(parentName) { setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(add_pc_to_db())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); } public slots: void add_pc_to_db(); QString mParentName;};
public slots: void add_pc_to_db(); QString mParentName; // };
void FMain::add_sub_group(){ QString names = trWd_tree->currentItem()->text(0); // show Window to ad new PC F_addPc *nF_addPc = new F_addPc(this); //nF_addPc->gr_name = names; nF_addPc->setAttribute(Qt::WA_DeleteOnClose); nF_addPc->show();}
public slots: void add_pc_to_db(); private: QString mParentName; };
void FMain::add_sub_group(){ QString names = trWd_tree->currentItem()->text(0); // show Window to ad new PC F_addPc *nF_addPc = new F_addPc(names, this);
class F_addPc : public QWidget, private Ui::F_addPc{ Q_OBJECT public: F_addPc(const QString & parentName, QWidget *parent = 0) : QWidget(parent), mParentName(parentName) { setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(add_pc_to_db())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); } public slots: void add_pc_to_db(); public: QString mParentName;};
void FMain::add_sub_group(){ QString names = trWd_tree->currentItem()->text(0); // show Window to ad new PC F_addPc *nF_addPc = new F_addPc(names, this); nF_addPc->setAttribute(Qt::WA_DeleteOnClose); nF_addPc->show();}
class F_addPc : public QWidget, private Ui::F_addPc{ Q_OBJECT public: F_addPc(QWidget *parent = 0) { setupUi(this);...
F_addPc(const QString & parentName, QWidget *parent = 0) : QWidget(parent), mParentName(parentName){..
C++ (Qt)FDialog(const QString &parentName, QDialog *parent = 0) : QDialog(parent), mParentName(parentName)
C++ (Qt)class FDialog : public QDialog, private Ui::FDialog{ Q_OBJECT public: FDialog(const QString &parentName, QDialog *parent = 0) : QDialog(parent), mParentName(parentName) { setupUi(this); connect(editPc, SIGNAL(clicked()), this, SLOT(editPcData())); connect(editCancel, SIGNAL(clicked()), this, SLOT(close())); } public slots: void editPcData(); public: QString mParentName;};
C++ (Qt)void FMain::showEditWindow(){ QString names = FMain::trWd_tree->currentItem()->text(0); FDialog *nFDialog = new FDialog(names, 0); nFDialog->setModal(true); nFDialog->setAttribute(Qt::WA_DeleteOnClose); nFDialog->show();}