首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从QTab (在QTabWidget中)连接回QMainWindow

从QTab (在QTabWidget中)连接回QMainWindow
EN

Stack Overflow用户
提问于 2013-04-07 22:23:31
回答 1查看 518关注 0票数 0

我的应用程序的主要部分是Systray-Menu。对于维护来说,应该有一个正常的GUI。

我的问题是,现在我必须创建两个信号/插槽连接,从每个选项卡返回到MainWindow。这是为了最小化GUI和更新菜单。我不知道该怎么做。

我尝试从ManageSession连接到this->parent->parent,从MainWindow连接到ui_manag->session_ui->minimizeButton。我脑子里有个小结,想寻求帮助。或者我应该重新考虑我的设计?我只使用带有Qt 4.8.4的QtCreator 2.6.1。

Screenshots of the GUI-Elements

这是mainwindows.cpp:

代码语言:javascript
运行
复制
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
}

选项卡完全由设计者生成:

代码语言:javascript
运行
复制
ManageTab::ManageTab(QWidget *parent) :
QTabWidget(parent),
tab_ui(new Ui::ManageTab)
{
 tab_ui->setupUi(this);
}

对于每个设置,我使用具有多个继承的相同GUI:

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-09 05:55:40

让我们在答案中重写它(这样你就可以接受它了,哈哈。j/k,渴望评论):

第一。正如我在评论中所说:

您正在继承,但未指定访问权限。所以它默认是私有的。怪不得

代码语言:javascript
运行
复制
ui_manag->session_ui->minimizeButton  

不允许您访问该按钮。

第二。parent是一个方法,所以它是: this->parent()->parent()或者只是parent()->parent() ;),它可能需要继承公共的。不确定,谢谢。那么这应该是可行的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15863441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档