Results 1 to 13 of 13

Thread: Addind Widgets

  1. #1
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Addind Widgets

    Curently doing main project in linux.After creating GUI now when a new widget is added, while running
    it is not seen.Also when i checked the corresponding .h file . there the corresponding code was also absent

  2. #2
    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: Addind Widgets

    How are you adding the new widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    i tried to add widgets in Qt in the existing project by just dragging and dropping.It appearis in the UI,but after building and running i cannot see my new widget added

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    Did you save the ui file ?
    Also run qmake again and see if it appears

  5. #5
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    yes i saved the ui file.In the ui_mainwindow.h file added widget's code is present. Tried run qmake but still cannot solve the problem

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Addind Widgets

    Can you post the code or a minimal compilable example that demonstrates the problem?

  7. #7
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    Qt Code:
    1. #ifndef UI_MAINWINDOW_H
    2. #define UI_MAINWINDOW_H
    3.  
    4.  
    5. //Push button_6 and push button_7 does not appear in the gui when i run the project.but it s n the file
    6.  
    7.  
    8.  
    9. #include <QtCore/QVariant>
    10. #include <QtGui/QAction>
    11. #include <QtGui/QApplication>
    12. #include <QtGui/QButtonGroup>
    13. #include <QtGui/QHeaderView>
    14. #include <QtGui/QMainWindow>
    15. #include <QtGui/QMenu>
    16. #include <QtGui/QMenuBar>
    17. #include <QtGui/QPushButton>
    18. #include <QtGui/QStatusBar>
    19. #include <QtGui/QToolBar>
    20. #include <QtGui/QWidget>
    21.  
    22. QT_BEGIN_NAMESPACE
    23.  
    24. class Ui_MainWindow
    25. {
    26. public:
    27. QWidget *centralWidget;
    28. QPushButton *pushButton;
    29. QPushButton *pushButton_2;
    30. QPushButton *pushButton_3;
    31. QPushButton *pushButton_4;
    32. QPushButton *pushButton_5;
    33. QPushButton *pushButton_6;
    34. QPushButton *pushButton_7;
    35. QMenuBar *menuBar;
    36. QMenu *menuCONTROL_CENTER;
    37. QToolBar *mainToolBar;
    38. QStatusBar *statusBar;
    39.  
    40. void setupUi(QMainWindow *MainWindow)
    41. {
    42. if (MainWindow->objectName().isEmpty())
    43. MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    44. MainWindow->resize(600, 347);
    45. centralWidget = new QWidget(MainWindow);
    46. centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
    47. pushButton = new QPushButton(centralWidget);
    48. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    49. pushButton->setGeometry(QRect(50, 50, 171, 41));
    50. pushButton_2 = new QPushButton(centralWidget);
    51. pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
    52. pushButton_2->setGeometry(QRect(360, 50, 171, 41));
    53. pushButton_3 = new QPushButton(centralWidget);
    54. pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));
    55. pushButton_3->setGeometry(QRect(50, 180, 171, 41));
    56. pushButton_4 = new QPushButton(centralWidget);
    57. pushButton_4->setObjectName(QString::fromUtf8("pushButton_4"));
    58. pushButton_4->setGeometry(QRect(360, 180, 171, 41));
    59. pushButton_5 = new QPushButton(centralWidget);
    60. pushButton_5->setObjectName(QString::fromUtf8("pushButton_5"));
    61. pushButton_5->setGeometry(QRect(240, 250, 91, 27));
    62. pushButton_6 = new QPushButton(centralWidget);
    63. pushButton_6->setObjectName(QString::fromUtf8("pushButton_6"));
    64. pushButton_6->setGeometry(QRect(200, 130, 96, 27));
    65. pushButton_7 = new QPushButton(centralWidget);
    66. pushButton_7->setObjectName(QString::fromUtf8("pushButton_7"));
    67. pushButton_7->setGeometry(QRect(370, 130, 96, 27));
    68. MainWindow->setCentralWidget(centralWidget);
    69. menuBar = new QMenuBar(MainWindow);
    70. menuBar->setObjectName(QString::fromUtf8("menuBar"));
    71. menuBar->setGeometry(QRect(0, 0, 600, 27));
    72. menuCONTROL_CENTER = new QMenu(menuBar);
    73. menuCONTROL_CENTER->setObjectName(QString::fromUtf8("menuCONTROL_CENTER"));
    74. MainWindow->setMenuBar(menuBar);
    75. mainToolBar = new QToolBar(MainWindow);
    76. mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
    77. MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
    78. statusBar = new QStatusBar(MainWindow);
    79. statusBar->setObjectName(QString::fromUtf8("statusBar"));
    80. MainWindow->setStatusBar(statusBar);
    81.  
    82. menuBar->addAction(menuCONTROL_CENTER->menuAction());
    83.  
    84. retranslateUi(MainWindow);
    85. QObject::connect(pushButton, SIGNAL(clicked()), MainWindow, SLOT(update()));
    86. QObject::connect(pushButton_5, SIGNAL(clicked()), MainWindow, SLOT(close()));
    87. QObject::connect(pushButton_2, SIGNAL(clicked()), MainWindow, SLOT(update()));
    88.  
    89. QMetaObject::connectSlotsByName(MainWindow);
    90. } // setupUi
    91.  
    92. void retranslateUi(QMainWindow *MainWindow)
    93. {
    94. MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    95. pushButton->setText(QApplication::translate("MainWindow", "Date and Time", 0, QApplication::UnicodeUTF8));
    96. pushButton_2->setText(QApplication::translate("MainWindow", "Display Settings", 0, QApplication::UnicodeUTF8));
    97. pushButton_3->setText(QApplication::translate("MainWindow", "Networking", 0, QApplication::UnicodeUTF8));
    98. pushButton_4->setText(QApplication::translate("MainWindow", "User Accounts", 0, QApplication::UnicodeUTF8));
    99. pushButton_5->setText(QApplication::translate("MainWindow", "Cancel", 0, QApplication::UnicodeUTF8));
    100. pushButton_6->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
    101. pushButton_7->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
    102. menuCONTROL_CENTER->setTitle(QApplication::translate("MainWindow", "CONTROL CENTER", 0, QApplication::UnicodeUTF8));
    103. } // retranslateUi
    104.  
    105. };
    106.  
    107. namespace Ui {
    108. class MainWindow: public Ui_MainWindow {};
    109. } // namespace Ui
    110.  
    111. QT_END_NAMESPACE
    112.  
    113. #endif // UI_MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 23rd January 2011 at 08:31. Reason: missing [code] tags

  8. #8
    Join Date
    Mar 2008
    Location
    Marslev, Denmark
    Posts
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Addind Widgets

    When adding a widget to a window/widget that is already shown, you have to call setVisible() yourself.
    Bo Thorsen, Viking Software
    Qt applications on Linux and Windows

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Addind Widgets

    I can't see that you are using layouts. Resize you window and see if the button are really not there or even better use layouts. And make sure the files get really recompiled.

  10. #10
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    How should i use setvisible().When i just drag and drop it appears when i run i cannnot see the buttom.Also in my system in the ui_mainwindow.h header file it s not listed.But in my friends system it is listed in the header file,but still it does not appear while running


    Added after 29 minutes:


    void MainWindow:n_pushButton_6_clicked()
    {
    ui->pushButton_6->setVisible(true);
    }
    //I tried using this code.Is this enough.
    Still i cant solve the problem
    Last edited by nighil; 23rd January 2011 at 13:47.

  11. #11
    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: Addind Widgets

    Please just use layouts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Jan 2011
    Posts
    16
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Addind Widgets

    i tried but it it is not working but the same Qt project when i added a widget in Qt installed in windows it worked

  13. #13
    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: Addind Widgets

    You are probably not rebuilding the whole project. Anyway, use layouts regardless of everything.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 16th December 2010, 11:52
  2. Replies: 2
    Last Post: 20th August 2010, 13:20
  3. Replies: 5
    Last Post: 18th April 2010, 23:31
  4. Replies: 0
    Last Post: 15th May 2009, 15:38
  5. Desktop widgets a la SuperKaramba/Opera Widgets
    By hubert.lepicki in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 22:49

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.