0

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 main window 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 I 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
rgettman
  • 176,041
  • 30
  • 275
  • 357
  • Could it be that inheriting from ui without specificating access is defaulting to private? So ui_manag->session_ui->minimizeButton wont work because minimizeButton is private. – trompa Apr 08 '13 at 09:24
  • Thank you for the hint with the access. I´m a step forward: I can now connect from the Managetab to the Button [connect(tab_ui->manageSessionTab->session_ui->minimizeButton, SIGNAL(clicked()), this, SLOT(hideMainWindowInManageTab()));]. But I cant connect from MainWindow to the TabWidget... – Markus Weber Apr 08 '13 at 17:22

1 Answers1

1

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.

trompa
  • 1,967
  • 1
  • 18
  • 26
  • My second problem was to include the "ui_managetab.h" in the "managetab.h". I only did it in the "managetab.cpp"... – Markus Weber Apr 10 '13 at 20:03
  • Now this is running very good: "connect(ui_manag->tab_ui->manageSessionTab->session_ui->minimizeButton, SIGNAL(clicked()), this, SLOT(hide()));" – Markus Weber Apr 10 '13 at 20:05
  • So in two or three weeks, I´ll release the new Version of my Firewall-Program on http://firewall.ztweb.de – Markus Weber Apr 10 '13 at 20:07