'How me get acces ui from another class?
I have a database in a separate widget class datbase.ui
that I insert as tab in mainwindow.ui
. I want that when initializing the connection in the class datbase.ui
statusbar in mainwindow.ui
to change depending.
datbase.cpp
void DatBase::on_pushButton_clicked()
{
QSqlDatabase ddbb = QSqlDatabase::addDatabase("QSQLITE");
ddbb.setDatabaseName(".../db/ddberdbsqlite");
if (ddbb.open()){
// It is necessary that this status is displayed in mainwindow.ui
// How to get access to gui mainwindow?
ui->statusBar->showMessage("Successful connection!");
}
else{
ui->statusBar->showMessage("Not Successful connection!");
}
}
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "datbase.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("Measurement DDEBR");
connect(ui->tabWidget, QTabWidget::currentChanged, this, MainWindow::showTabPageIndex);
DatBase *tabDatBase = new DatBase();
ui->tabWidget->insertTab(0, tabDatBase, "Data Base");
}
MainWindow::~MainWindow()
{
delete ui;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|