nighil
22nd January 2011, 16:24
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
wysota
22nd January 2011, 16:32
How are you adding the new widget?
nighil
23rd January 2011, 04:32
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
aamer4yu
23rd January 2011, 06:16
Did you save the ui file ?
Also run qmake again and see if it appears
nighil
23rd January 2011, 06:33
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
tbscope
23rd January 2011, 06:40
Can you post the code or a minimal compilable example that demonstrates the problem?
nighil
23rd January 2011, 06:52
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
//Push button_6 and push button_7 does not appear in the gui when i run the project.but it s n the file
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QPushButton *pushButton;
QPushButton *pushButton_2;
QPushButton *pushButton_3;
QPushButton *pushButton_4;
QPushButton *pushButton_5;
QPushButton *pushButton_6;
QPushButton *pushButton_7;
QMenuBar *menuBar;
QMenu *menuCONTROL_CENTER;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(600, 347);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
pushButton = new QPushButton(centralWidget);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(50, 50, 171, 41));
pushButton_2 = new QPushButton(centralWidget);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
pushButton_2->setGeometry(QRect(360, 50, 171, 41));
pushButton_3 = new QPushButton(centralWidget);
pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));
pushButton_3->setGeometry(QRect(50, 180, 171, 41));
pushButton_4 = new QPushButton(centralWidget);
pushButton_4->setObjectName(QString::fromUtf8("pushButton_4"));
pushButton_4->setGeometry(QRect(360, 180, 171, 41));
pushButton_5 = new QPushButton(centralWidget);
pushButton_5->setObjectName(QString::fromUtf8("pushButton_5"));
pushButton_5->setGeometry(QRect(240, 250, 91, 27));
pushButton_6 = new QPushButton(centralWidget);
pushButton_6->setObjectName(QString::fromUtf8("pushButton_6"));
pushButton_6->setGeometry(QRect(200, 130, 96, 27));
pushButton_7 = new QPushButton(centralWidget);
pushButton_7->setObjectName(QString::fromUtf8("pushButton_7"));
pushButton_7->setGeometry(QRect(370, 130, 96, 27));
MainWindow->setCentralWidget(centralWidget);
menuBar = new QMenuBar(MainWindow);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 600, 27));
menuCONTROL_CENTER = new QMenu(menuBar);
menuCONTROL_CENTER->setObjectName(QString::fromUtf8("menuCONTROL_CENTER"));
MainWindow->setMenuBar(menuBar);
mainToolBar = new QToolBar(MainWindow);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(MainWindow);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
MainWindow->setStatusBar(statusBar);
menuBar->addAction(menuCONTROL_CENTER->menuAction());
retranslateUi(MainWindow);
QObject::connect(pushButton, SIGNAL(clicked()), MainWindow, SLOT(update()));
QObject::connect(pushButton_5, SIGNAL(clicked()), MainWindow, SLOT(close()));
QObject::connect(pushButton_2, SIGNAL(clicked()), MainWindow, SLOT(update()));
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("MainWindow", "Date and Time", 0, QApplication::UnicodeUTF8));
pushButton_2->setText(QApplication::translate("MainWindow", "Display Settings", 0, QApplication::UnicodeUTF8));
pushButton_3->setText(QApplication::translate("MainWindow", "Networking", 0, QApplication::UnicodeUTF8));
pushButton_4->setText(QApplication::translate("MainWindow", "User Accounts", 0, QApplication::UnicodeUTF8));
pushButton_5->setText(QApplication::translate("MainWindow", "Cancel", 0, QApplication::UnicodeUTF8));
pushButton_6->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
pushButton_7->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
menuCONTROL_CENTER->setTitle(QApplication::translate("MainWindow", "CONTROL CENTER", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
bothorsen
23rd January 2011, 08:29
When adding a widget to a window/widget that is already shown, you have to call setVisible() yourself.
Lykurg
23rd January 2011, 08:34
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.
nighil
23rd January 2011, 13:47
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::on_pushButton_6_clicked()
{
ui->pushButton_6->setVisible(true);
}
//I tried using this code.Is this enough.
Still i cant solve the problem
nighil
23rd January 2011, 14:42
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
wysota
23rd January 2011, 16:34
You are probably not rebuilding the whole project. Anyway, use layouts regardless of everything.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.