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

    Quote Originally Posted by Salazaar View Post
    This is the .pro file
    Qt Code:
    1. CONFIG += qt
    2. HEADERS += ui_Maker.h
    3. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    Please follow the directions I already gave you once. There is no need to generate the header and include it to the project by hand. You should be using a variable FORMS instead.

    Edit: Clean up the folder. Leave only files main.cpp and Maker.ui. Run "qmake -project" and you'll get a proper project file.

    And this is what appear in console. There are really many errors such as:
    in main.cpp - undefined reference to...
    and the first error is [release\test.exe] error 1
    and second is
    [release] error 2
    Well, you managed to cut the interesting part off. "error 1" or "error 2" does not tell anything valuable. Please paste all the errors including the undefined reference.
    J-P Nurmi

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    Maybe he should paste only the first few?

    And remember about closing the memory leak when you come to this point

  3. #3
    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 wysota View Post
    Maybe he should paste only the first few?
    That's what I asked in the first place but it didn't work so I tried another approach..

    And remember about closing the memory leak when you come to this point
    First of all, I tried to advise against using the direct approach. Anyway, the same leak is also in the example..
    J-P Nurmi

  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 jpn View Post
    Please follow the directions I already gave you once. There is no need to generate the header and include it to the project by hand. You should be using a variable FORMS instead.
    But if I want to make changes in the maker file, which I can't do in Designer such as connecting tools->sort to another dialog, I have to generate header file and make changes and add it to project by hand. Is that right?
    EDIT:
    I have generated project file by makefile but there appear the same errors such as:
    in main.cpp - undefined reference to _imp__ZN7QString4freeEPNS
    What is wrong?
    EDIT:
    I think this is problem with my Qt installation, because when I try to compile simple application lioke this:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QPushButton hello("Hello world!");
    9. hello.resize(100, 30);
    10.  
    11. hello.show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    There appear errors such as undefined reference to QApplication, QPushButton and the same as in compiling converted ui file
    So, I'll ask once again. What's wrong? I have installed Qt to my mingw compiler, set 3 environment variables. I have done it with Marcel's help, so everything should be set.....
    Regards
    EDIT:
    Oh, now everything's ok, I just forgot to include QApplication to main file
    Last edited by wysota; 13th May 2007 at 14:41. Reason: Changed [qtclass] into [code]

  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

    Quote Originally Posted by Salazaar View Post
    But if I want to make changes in the maker file, which I can't do in Designer such as connecting tools->sort to another dialog, I have to generate header file and make changes and add it to project by hand. Is that right?
    As the generated header says in the header comment, do never edit them by hand. Your changes will be lost if you ever want do adjust the designed form and the header is generated again. Use either single inheritance or multiple inheritance approach and do the changes in the actual widget/dialog/window class (which loads the designed form).
    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 really don't understand what is described in this link.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 use the "code" tag (# button) instead of "qtclass" (Qt button) when pasting code.

  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

    So how can I connect other dialogs to my main windows action (it is all done with Qt Designer)

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

  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

    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?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.

  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

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

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

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

  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

    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.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.

  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

    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.

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

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

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