Page 3 of 6 FirstFirst 12345 ... LastLast
Results 41 to 60 of 105

Thread: Problem displaying my main window

  1. #41
    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, it works properly. And how can I connect other dialog to one of actions defined in ui_maker.h?? Because I can't understand multiple inheritance
    Last edited by Salazaar; 16th May 2007 at 22:00.

  2. #42
    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

    Quote Originally Posted by Salazaar View Post
    And how can I connect other dialog to one of actions defined in ui_maker.h??
    For example you can use the automatic connections mechanism, by adding a specially named slot to your class:
    Qt Code:
    1. void MainWindow::on_someAction_triggered()
    2. {
    3. OtherDialog dlg( this );
    4. dlg.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Where someAction is the name of the action you want to connect to and triggered() is the signal you want to react on.

    Quote Originally Posted by Salazaar View Post
    Because I can't understand multiple inheritance
    It looks like you have taken the single inheritance approach, so you don't use the multiple inheritance anywhere.

  3. #43
    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, so I create slot:
    Qt Code:
    1. void MainWindow::on_actionAbout_triggered()
    2.  
    3. {
    4.  
    5. OtherDialog dlg( this );
    6.  
    7. dlg.exec();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 
    And, what's the next step?

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

    Can't you just follow a tutorial or something? It'll be way faster if you do...

  5. #45
    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 Salazaar View Post
    Because I can't understand multiple inheritance
    So I'd like you to show me how to do it, please.Regarsds
    Last edited by Salazaar; 17th May 2007 at 17:31.

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

    Quote Originally Posted by Salazaar View Post
    And, what's the next step?
    Compilation

    Qt will handle the rest, provided that you have that OtherDialog class. How does your main() function look like?

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

    What does multiple inheritance have to do with the code you pasted above?

    Here is a list of different examples and tutorials which you might want to take a look at:
    http://doc.trolltech.com/4.2/examples.html

    Here is an article stating step by step how to use forms created in Designer:
    http://doc.trolltech.com/4.2/designe...component.html

    Here is a link to The Independent Qt Tutorial by Johan Thelin which is a tutorial on Qt3 for beginners. If you have trouble handling Qt basics, it'll be fine for you even if you use Qt4:
    http://www.digitalfanatics.org/projects/qt_tutorial/

    The problem is that you're asking questions without telling us what you want. In particular I have no idea what "next step" you were referring to in your previous post. We don't know what you already did, what you're planning to do, etc.

  8. #48
    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 jacek View Post
    Qt will handle the rest, provided that you have that OtherDialog class.
    You're assuming he has a actionAbout action in his class

  9. #49
    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 jacek View Post
    Compilation

    Qt will handle the rest, provided that you have that OtherDialog class
    I don't understand. The only thing that I have to do is defining this? But what should be in OtherDialog and dlg places in my case, if I have a Main Window called MainWindow and all actions defined in ui_maker.h file? This file is designed by designer. And I have to include this ui_Dialog file, yes? Regards

  10. #50
    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 jacek View Post
    Compilation

    Qt will handle the rest, provided that you have that OtherDialog class
    I don't understand. The only thing that I have to do is defining this? But what should be in OtherDialog and dlg places in my case, if I have a Main Window called MainWindow and a dialog called Dialog? All actions aredefined in ui_maker.h file, this file is designed by designer. I have this two files: maker.h:
    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 
    and ui_about:
    Qt Code:
    1. #ifndef UI_ABOUT_H
    2. #define UI_ABOUT_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QDialog>
    9. #include <QtGui/QLabel>
    10. #include <QtGui/QPushButton>
    11.  
    12. class Ui_Dialog
    13. {
    14. public:
    15. QLabel *label;
    16. QLabel *label_2;
    17. QLabel *label_3;
    18. QPushButton *pushButton;
    19.  
    20. void setupUi(QDialog *Dialog)
    21. {
    22. Dialog->setObjectName(QString::fromUtf8("Dialog"));
    23. label = new QLabel(Dialog);
    24. label->setObjectName(QString::fromUtf8("label"));
    25. label->setGeometry(QRect(15, 23, 361, 16));
    26. label->setLayoutDirection(Qt::LeftToRight);
    27. label->setTextFormat(Qt::AutoText);
    28. label_2 = new QLabel(Dialog);
    29. label_2->setObjectName(QString::fromUtf8("label_2"));
    30. label_2->setGeometry(QRect(15, 50, 351, 81));
    31. label_2->setLineWidth(1);
    32. label_2->setMidLineWidth(0);
    33. label_2->setTextFormat(Qt::RichText);
    34. label_2->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    35. label_2->setWordWrap(true);
    36. label_3 = new QLabel(Dialog);
    37. label_3->setObjectName(QString::fromUtf8("label_3"));
    38. label_3->setGeometry(QRect(25, 163, 171, 21));
    39. pushButton = new QPushButton(Dialog);
    40. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    41. pushButton->setGeometry(QRect(260, 250, 75, 23));
    42. pushButton->setDefault(true);
    43. pushButton->setFlat(false);
    44.  
    45. retranslateUi(Dialog);
    46.  
    47. QSize size(400, 293);
    48. size = size.expandedTo(Dialog->minimumSizeHint());
    49. Dialog->resize(size);
    50.  
    51. QObject::connect(pushButton, SIGNAL(clicked()), Dialog, SLOT(close()));
    52.  
    53. QMetaObject::connectSlotsByName(Dialog);
    54. } // setupUi
    55.  
    56. void retranslateUi(QDialog *Dialog)
    57. {
    58. Dialog->setWindowTitle(QApplication::translate("Dialog", "About", 0, QApplication::UnicodeUTF8));
    59. Dialog->setAccessibleName(QApplication::translate("Dialog", "About", 0, QApplication::UnicodeUTF8));
    60. label->setText(QApplication::translate("Dialog", "About TimeTable Maker", 0, QApplication::UnicodeUTF8));
    61. label_2->setText(QApplication::translate("Dialog", "...", 0, QApplication::UnicodeUTF8));
    62. label_3->setText(QApplication::translate("Dialog", "Thank you for using TimeTable Maker", 0, QApplication::UnicodeUTF8));
    63. pushButton->setText(QApplication::translate("Dialog", "OK", 0, QApplication::UnicodeUTF8));
    64. Q_UNUSED(Dialog);
    65. } // retranslateUi
    66.  
    67. };
    68.  
    69. namespace Ui {
    70. class Dialog: public Ui_Dialog {};
    71. } // namespace Ui
    72.  
    73. #endif // UI_ABOUT_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 17th May 2007 at 21:50. Reason: shortened too long line

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

    I think you mentioned you have the book "GUI Programming with Qt4". Did you read the second chapter? Especially sections "Subclassing QDialog" and "Rapid Dialog Design"? These explain how to do what you're trying to do.

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

    No, but I'll read it Ok, so I will look at it

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

    Don't have a look. Read it.

  14. #54
    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 after it I will know how to do it...I would like to know

  15. #55
    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

    Yes. You're asking about very simple things and it seems that you even didn't look at the documentation or the book. We won't teach you C++ here. If you have trouble with C++ I suggest you also take a look at our links section and download (and read, at least parts of it) "Thinking in C++".

  16. #56
    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'd like the Chapter 2 to be simplier than designer using a component? But there isn't much to do with the code in post #50, right?

  17. #57
    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

    Read and understand the chapter. We can give you the exact code for your problem but then you won't learn anything and you'll come right back with a simmilar issue.

  18. #58
    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 book, there appear one more line after QApplication app... It's
    Qt Code:
    1. Ui::MainWindow ui
    To copy to clipboard, switch view to plain text mode 
    which not appear in my application, but it works.

  19. #59
    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 than. I read chapter 2, I understand it, but I still don't know how to connect action to another dialog. It shows how to make slots and use it, but not how to connect two different dialogs. Regards

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

    Quote Originally Posted by Salazaar View Post
    but not how to connect two different dialogs.
    What do you mean by "connect two different dialogs"? Do you want to connect a signal from one dialog to a slot in the other one?

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.