Hello all, I am fairly new to Qt so do not know all the ins and outs yet but I am attepting to create a simple matrix program with the results beign that when one parameter changes in the main window the widget is affected and shows the results. I have been reading online forums and all seem to say that interaction with Ui of the main window and the Ui of the widget is not allowed I also found another thread with a sample code on how to make it work (I will also post in bottom.) the code seemed to work but when attempting to compile several error messages came up
#include <QMainWindow>
#include "array.h"
#include "matrix.h"
//trying to get windows to recognize Matrix ui
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
Ui::MainWindow *ui;//made ui public instead of private
Ui::Matrix*yw;//Here is the change I was recomended to add the widget class Ui to my main window
private:
protected:
private slots:
void on_radioButton_clicked(bool checked);
};
#endif // MAINWINDOW_H
#include <QMainWindow>
#include "array.h"
#include "matrix.h"
//trying to get windows to recognize Matrix ui
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
Ui::MainWindow *ui;//made ui public instead of private
Ui::Matrix*yw;//Here is the change I was recomended to add the widget class Ui to my main window
private:
protected:
void mousePressEvent(QMouseEvent * e);
private slots:
void on_radioButton_clicked(bool checked);
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
Then in my Cpp file i added this line
void MainWindow::on_radioButton_clicked(bool checked)
{
yw->label->setText("on");//Also recommendation
}
void MainWindow::on_radioButton_clicked(bool checked)
{
yw->label->setText("on");//Also recommendation
}
To copy to clipboard, switch view to plain text mode
here is the error I recieved after compilation
ui_mainwindow.h:39: error: 'Matrix' does not name a type//
When this did'nt work I made some changes to the Cpp again attempting to establish a parent child relationship with the widget and main window but I am not sure if I was succesful
ui(new Ui::MainWindow),matrix(new Ui::Matrix)//here is what I changed
{
ui->setupUi(this);
matrix->setupUi(this->ui->centralWidget);//Added this
ui(new Ui::MainWindow),matrix(new Ui::Matrix)//here is what I changed
{
ui->setupUi(this);
matrix->setupUi(this->ui->centralWidget);//Added this
To copy to clipboard, switch view to plain text mode
I am at a bit of a dead end with how to approach this now hope someone can help
Bookmarks