Page 2 of 6 FirstFirst 1234 ... LastLast
Results 21 to 40 of 105

Thread: Problem displaying my main window

  1. #21
    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 C++ GUI Programming with Qt 4 book. And I know something already, but I can't do anything about that, so I will ask you once more, to correct my code

  2. #22
    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 added this:
    Qt Code:
    1. void Ui_MainWindow::openUi_Dialog(){
    2. static Ui_Dialog *Ui_Dialog = new Ui_Dialog(this);
    3. Ui_Dialog->show();
    4. Ui_Dialog->activateWindow(); // or form2->setActiveWindow() in Qt3
    5. Ui_Dialog->raise();
    6. }
    To copy to clipboard, switch view to plain text mode 
    into Ui_MainWindow class. Is that correctly?
    EDIT:
    No, it isn't. When I do it I have errors that MainWindow class does not have a member called raise, acitvateWindow and show. Even if I paste it out of this class there are errors:
    class Ui-Dialog has no member called raise, show and activateWindow. So how should I do it?
    Last edited by Salazaar; 13th May 2007 at 21:02.

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

    Again with big red characters:

    Don't change the code of the class generated by UIC. Subclass along the proper widget class and put additional code there.

    There... I hope that makes it clear Oh... and I'm sure it's well explained in the book you mentioned.

  4. #24
    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

    Ok, I won't change the code, so how can I connect dialog to actionAbout slot? I'd be satisfied with a code.
    Regards
    -------------------
    Widzę, że nie jestem sam na tym forum

  5. #25
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

    You don't have a dialog. You only have an UI definition. You have to use the definition on a dialog and not on its own. You're asking for code and we're constantly redirecting you to an article that contains the code you ask for. Furthermore GUI Programming with Qt4 book also contains the code you ask for. Please read and follow "The Single Inheritance Approach" section from the docs.

  6. #26
    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

    Right. Than, I have a question concerning code that jpn gave me:
    Qt Code:
    1. #include "ui_Maker.h"
    2.  
    3.  
    4.  
    5. int main(int argc, char *argv[])
    6.  
    7. {
    8.  
    9. QApplication app(argc, argv);
    10.  
    11. QMainWindow *window = new QMainWindow; // create a main window, that's what you have designed
    12.  
    13. Ui::MainWindow ui;
    14.  
    15. ui.setupUi(window);
    16.  
    17. window->show();
    18.  
    19. return app.exec();
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 
    Why it's
    Qt Code:
    1. Ui::MainWindow ui
    To copy to clipboard, switch view to plain text mode 
    ? I didn't find anything what should be called by this.

  7. #27
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem displaying my main window

    Quote Originally Posted by Salazaar View Post
    Why it's
    Qt Code:
    1. Ui::MainWindow ui
    To copy to clipboard, switch view to plain text mode 
    ? I didn't find anything what should be called by this.
    The name was picked from Marker.ui pasted in the very first post of yours. However, it was only an attempt to get you going. You really should forget about the direct approach and use better alternates.
    J-P Nurmi

  8. #28
    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

    Like The Single Inheritance Approach and The Multiple Inheritance Approach ... Ok, I'm working at it... and this MainWindow is the name of my main window which I gave to it by designer, right?

  9. #29
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem displaying my main window

    Quote Originally Posted by Salazaar View Post
    and this MainWindow is the name of my main window which I gave to it by designer, right?
    That's right.
    J-P Nurmi

  10. #30
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem displaying my main window

    I use a tool to create cpp (source) && h (header file)


    Finaly on main to show the gui you use on main...
    ## MainWindow is class name....
    MainWindow::self()->setWindowTitle( _PROGRAM_TITLE_ );
    MainWindow::self()->show();


    download QTutils tool -> http://ppk.ciz.ch/qt_c++/QT_utils.zip
    cd QT_utils
    qmake
    make

    Open QTUtils insert the class name on top && select mainwindow/Dialog/Widged type same as ui file && generate the code as header & source ... or only as header....

    Put the file on projekt dir && run && main.cpp
    on cmd dir qmake -project
    call the dialog on main...

    but on top from pro file ...

    MOC_DIR = build/.moc
    RCC_DIR = build/.rcc
    OBJECTS_DIR = build/.obj
    UI_DIR = ui

    and final
    qmake && make.
    Attached Images Attached Images

  11. #31
    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 Direct Approach shows how to show the dialog, not to make changes in it. And to not to make a new thread, I'll ask here, can I create slots in designer? And in this code, which is here: http://doc.trolltech.com/4.2/designe...tance-approach
    I have to paste into main.cpp file, right?
    Edit:
    Patrik, there's no problem with creating main file, but with connecting mainwindow to other applications and with creating slots
    Last edited by Salazaar; 14th May 2007 at 10:01.

  12. #32
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem displaying my main window

    Quote Originally Posted by Salazaar View Post
    But Direct Approach shows how to show the dialog, not to make changes in it. And to not to make a new thread, I'll ask here, can I create slots in designer?
    No, you can't create slots in Designer.

    And in this code, which is here: http://doc.trolltech.com/4.2/designe...tance-approach
    I have to paste into main.cpp file, right?
    Look at the Calculator Form Example. It uses the single inheritance approach and custom slots.
    J-P Nurmi

  13. #33
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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
    And to not to make a new thread, I'll ask here, can I create slots in designer?
    http://www.qtcentre.org/forum/faq.ph...igner_category

  14. #34
    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 jpn View Post
    No, you can't create slots in Designer.


    Look at the Calculator Form Example.
    But in http://doc.trolltech.com/4.2/designe...tance-approach it shows how to add a custom slot, but it doesn't show how to connect action to another dialog
    Last edited by Salazaar; 14th May 2007 at 20:01.

  15. #35
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

    Please connect all the knowledge gathered in this thread and use it together. If you have any doubt, consult the FAQ and the article you were given. If you still have problems, ask *specific* questions.

  16. #36
    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

    Hi. So, I've got a question. There appear errors:

    In member function void MainWindow::cbazion()
    expected primary-expression before ) token
    expected ; before) token
    expected } at end of input

    And this is this file:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "maker.h"
    4.  
    5. MainWindow::MainWindow(QMainWindow *parent)
    6. : QMainWindow(parent)
    7. {
    8. ui.setupUi(this);
    9. }
    10.  
    11. void MainWindow::abcziom()
    12. {
    13.  
    14. }
    15.  
    16. void MainWindow::cbaziom()
    17. {
    18.  
    19. )
    To copy to clipboard, switch view to plain text mode 

  17. #37
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem displaying my main window

    Could you post the contents of maker.h file?

  18. #38
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

    You have a right bracket instead of a right brace in the last line.

  19. #39
    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

    This is the full maker.h content:
    Qt Code:
    1. #ifndef MAKER_H
    2. #define MAKER_H
    3.  
    4. #include "ui_maker.h"
    5.  
    6. class MainWindow : public QMainWindow
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. MainWindow(QMainWindow *parent = 0);
    12.  
    13. private slots:
    14. void abcziom();
    15. void cbaziom();
    16.  
    17. private:
    18. Ui::MainWindow ui;
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 
    So, what's wrong?

  20. #40
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

    As I said, you have a wrong character in your implementation file.

Similar Threads

  1. Replies: 15
    Last Post: 23rd March 2007, 17:16
  2. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 09:41
  3. Problem in porting Main window on linux
    By jyoti kumar in forum Qt Tools
    Replies: 2
    Last Post: 2nd June 2006, 09:35
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 21st March 2006, 00: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.