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
    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

    J-P Nurmi

  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

    Ok, thanks, I'll try it. But if I want to make things, which I can't do in Designer, so how can I make these changes without changing code?

  3. #3
    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

    Look again at the links JP gave you in post #12.

  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

    Hi. I tried to do what's described in http://www.qtcentre.org/forum/faq.ph...esigner_2forms
    but I don't know how to do it. I'd be veery thankful if somebody will do it on my code and add comments in the parts of code which were changed:

    Dialog file which I want to connect to actionAbout http://www.insidetennis.yoyo.pl/ui_About.txt

    And my main window
    http://www.insidetennis.yoyo.pl/ui_MainWindow.txt (Attention! The file is called ui_maker.h, not ui_mainwindow.h !!!)

    if someone can do it, I'd be very thankful...

  5. #5
    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

    Please, consider going through the nice tutorials shipped with Qt, starting from Qt Tutorial 1 - Hello World. We are not here to teach you the basics but to help you with problems you may encounter.
    J-P Nurmi

  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

    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

  7. #7
    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 20:02.

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

  9. #9
    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

  10. #10
    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.

  11. #11
    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.

  12. #12
    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

  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

    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?

  14. #14
    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

  15. #15
    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 09:01.

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

  17. #17
    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 19:01.

  18. #18
    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

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

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.