Results 1 to 20 of 105

Thread: Problem displaying my main window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    Do you have a class called "OtherDialog"?

  2. #2
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    Quote Originally Posted by wysota View Post
    Do you have a class called "OtherDialog"?
    No, I don't have a class called OtherDialog and also don't have class called Dialog (btw. my dialog is called Dialog) How (and where) do I have to create this class? Look at the code I'd posted above. Regards

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    So if you don't have such classes, why are you using them? You have to create a subclass of QDialog that uses your uic generated code to initialise itself which is explained in the link you're constantly being pointed to.

    Please, understand, there is nothing magical going on here. If you don't implement a class, you can't use it - it won't be created out of thin air. I asked you about your C++ knowledge and I was given an empty answer, but from what I see you don't know much about it. So I repeat Jacek's suggestion to take a good book about C++, be it either C++ Primer, Thinking in C++ (available online) or even Symfonia C++.

    The problem here is that if we don't give you exact code you are to copy and paste into your files, there is no way you're going to obtain the result you want, because you don't seem to try to do anything by yourself. It seems that you know what to do, because you implemented the exact same thing that is required here with the main window. I just can't seem to understand why don't you repeat the exact same approach with the dialog.
    We're all trying to teach you something here, but it seems we're doing something wrong, so please explain us what exactly you don't know how to do and I'm speaking of some fundamental things - like subclassing, creating variables, single or multiple inheritance, etc. Is this all known to you? Do you have any trouble handling those basics?

  4. #4
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    Quote Originally Posted by wysota View Post
    Do you have any trouble handling those basics?
    A bit. Do I have to subclass this Dialog in the same way I was subclassing MainWindow?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    Quote Originally Posted by Salazaar View Post
    A bit.
    Great, now we're getting somewhere. Please, if at any time you don't understand what we say (any term, code, etc.) just say so and we'll explain it.

    Do I have to subclass this Dialog in the same way I was subclassing MainWindow?
    Yes. This is exactly the same situation - you have a UI definition in one class and you want to apply it to a widget class (like QDialog or QMainWindow).

  6. #6
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    Quote Originally Posted by wysota View Post
    Great, now we're getting somewhere. Please, if at any time you don't understand what we say (any term, code, etc.) just say so and we'll explain it.
    Thanks

    And can I subclass dialog in the same file I was subclassing MainWindow (maker.h, and include ui_about.h, ui_maker.h) ?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    Yes, but I suggest you use separate pair of files for that. You'll get cleaner code and faster compilation.

  8. #8
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    But in this case (subclassing QDialog) I don't define slots, do I?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    Do you need any?

  10. #10
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    I suppouse no, because I'd defined all importand slots when I was subclassing MainWindow

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem displaying my main window

    So the answer is no, you don't define slots

  12. #12
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    Thanks And I've got one more question, why some slots are defined in private slots and some are defined in private? Both are private sections of MainWindow class, what's the difference?

  13. #13
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    And in maker.cpp I have to do the same what I was doing with MainWindow:
    Qt Code:
    1. MainWindow::MainWindow(QMainWindow *parent)
    2. : QMainWindow(parent)
    3. {
    4. ui.setupUi(this);
    5.  
    6. }
    7.  
    8. void MainWindow::on_actionAbout_triggered()
    9. {
    10.  
    11.  
    12. Dialog dlg( this );
    13.  
    14.  
    15.  
    16. dlg.exec();
    17.  
    18.  
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 
    but without implementing slots, right?

  14. #14
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem displaying my main window

    I have a problem. I've implemented this:
    Maker.h
    Qt Code:
    1. #ifndef MAKER_H
    2. #define MAKER_H
    3.  
    4. #include "ui_maker.h"
    5.  
    6.  
    7.  
    8. class MainWindow : public QMainWindow, public Ui::MainWindow
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. MainWindow(QMainWindow *parent = 0);
    14.  
    15. private slots:
    16.  
    17. void on_actionAbout_triggered();
    18.  
    19. private:
    20.  
    21. Ui::MainWindow ui;
    22. };
    23.  
    24. #endif
    To copy to clipboard, switch view to plain text mode 

    About.h
    Qt Code:
    1. #ifndef ABOUT_H
    2. #define ABOUT_H
    3.  
    4. #include "ui_about.h"
    5.  
    6.  
    7.  
    8. class Dialog : public QDialog, public Ui::Dialog
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. Dialog(QDialog *parent = 0);
    14.  
    15.  
    16. private:
    17.  
    18. Ui::Dialog ui;
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 

    Maker.cpp
    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "maker.h"
    4. #include "about.h"
    5.  
    6. MainWindow::MainWindow(QMainWindow *parent)
    7. : QMainWindow(parent)
    8. {
    9. ui.setupUi(this);
    10.  
    11. }
    12.  
    13. void MainWindow::on_actionAbout_triggered()
    14. {
    15.  
    16.  
    17. Dialog dlg( this );
    18.  
    19.  
    20.  
    21. dlg.exec();
    22.  
    23.  
    24.  
    25. }
    26.  
    27.  
    28.  
    29.  
    30. Dialog::Dialog(QDialog *parent)
    31. : QDialog(parent)
    32. {
    33. ui.setupUi(this);
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 

    And also main.cpp, which contents I won't post, because it's obvious. And there appear errors:
    maker.cpp:in member function 'void MainWindow:n_actionAbout_triggered()':
    maker.cpp:17:error: no matching function for call to 'Dialog:ialog(MainWindow* const)
    about.h:9:note: candidates are Dialog:ialog(const Dialog&)
    about.h:13:note: Dialog:ialog(QDialog*)

    What's wrong? I thought I'd done everything as it was described in C++ GUI and in this topic. Regards
    p.s.
    Forum mechanism replaced : D with a smile and also : o with the other smile, as you seen so far

Similar Threads

  1. Replies: 15
    Last Post: 23rd March 2007, 16:16
  2. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  3. Problem in porting Main window on linux
    By jyoti kumar in forum Qt Tools
    Replies: 2
    Last Post: 2nd June 2006, 08:35
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 20th March 2006, 23:54

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.