Results 1 to 5 of 5

Thread: WIdget relationship with Main Window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default WIdget relationship with Main Window

    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
    Qt Code:
    1. #include <QMainWindow>
    2. #include "array.h"
    3. #include "matrix.h"
    4. //trying to get windows to recognize Matrix ui
    5. namespace Ui {
    6. class MainWindow;
    7. }
    8.  
    9. class MainWindow : public QMainWindow
    10. {
    11. Q_OBJECT
    12.  
    13. public:
    14. explicit MainWindow(QWidget *parent = 0);
    15. ~MainWindow();
    16. Ui::MainWindow *ui;//made ui public instead of private
    17. Ui::Matrix*yw;//Here is the change I was recomended to add the widget class Ui to my main window
    18.  
    19.  
    20.  
    21. private:
    22.  
    23.  
    24. protected:
    25. void mousePressEvent(QMouseEvent * e);
    26. private slots:
    27. void on_radioButton_clicked(bool checked);
    28. };
    29.  
    30. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Then in my Cpp file i added this line
    Qt Code:
    1. void MainWindow::on_radioButton_clicked(bool checked)
    2. {
    3. yw->label->setText("on");//Also recommendation
    4. }
    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
    Qt Code:
    1. ui(new Ui::MainWindow),matrix(new Ui::Matrix)//here is what I changed
    2. {
    3. ui->setupUi(this);
    4. 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
    Last edited by Robobulls; 23rd May 2013 at 19:26.

Similar Threads

  1. Customizable widget over main window.
    By SeeLook in forum Qt Programming
    Replies: 5
    Last Post: 23rd June 2012, 16:24
  2. Replies: 2
    Last Post: 16th April 2012, 04:13
  3. Add a Frame Widget to the main window
    By kamlmish in forum Qt Programming
    Replies: 2
    Last Post: 30th November 2010, 08:51
  4. Replies: 0
    Last Post: 14th November 2010, 19:38
  5. accessing my main application window widget
    By jayw710 in forum Newbie
    Replies: 8
    Last Post: 15th November 2007, 19:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.