Domanda

The main Part of my Application is a Systray-Menu. For maintenance there should be a normal GUI.

My Problem is that now I have to create two Signal/Slot-Connections back to the MainWindow from each Tab. This is for minimizing the GUI and to update the Menu. I don't know how to do this.

I tried to connect with this->parent->parent from the ManageSession and ui_manag->session_ui->minimizeButton from MainWindow. I have a little knot in my head and am asking for help. Or should I re-think my design? I´m using only QtCreator 2.6.1 with Qt 4.8.4.

Screenshots of the GUI-Elements

This is the mainwindows.cpp:

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
 setWindowTitle(QCoreApplication::applicationName());
 QWidget *mainWidget = new QWidget;
 QTabWidget *ui_manag = new ManageTab;
 QVBoxLayout *mainLayout = new QVBoxLayout;
 mainLayout->addWidget(ui_manag);
 mainWidget->setLayout(mainLayout);
 setCentralWidget(ui_manag);
 ui_manag->setCurrentIndex(0);
 //Here comming Code to setup a TrayIcon, the Database and the Menus
}

The Tab is completely generated by the Designer:

ManageTab::ManageTab(QWidget *parent) :
QTabWidget(parent),
tab_ui(new Ui::ManageTab)
{
 tab_ui->setupUi(this);
}

For each Setting I use the same GUI with multiple inheritance:

ManageSession::ManageSession(QWidget *parent) :
QWidget(parent),
session_ui(new Ui::ManageWidget)
{
 session_ui->setupUi(this);
 session_ui->manageLabel->setText(tr("Manage Session"));

 connect(session_ui->addButton, SIGNAL(clicked()), this, SLOT(addButton_clicked()));
 connect(session_ui->editButton, SIGNAL(clicked()), this, SLOT(editButton_clicked()));
 connect(session_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteButton_clicked()));
}
//Here follows the Functions for manipulating the TableView
// and emmiting a Signal to Update the Menu
È stato utile?

Soluzione

Let's remake it in an answer (so you can accept it, hehe. j/k, to long for a comment):

First. As i said in comment:

You are inheriting without specifying access. So it defaults to private. That's why

ui_manag->session_ui->minimizeButton  

wont allow you to access the button.

Second. parent is a method, so It's: this->parent()->parent() or just parent()->parent() ;) Again, it probably needs to inherit public. Not sure, tho. That should work then.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top