Create window help
-
i am trying another example and something weird is going on here
this is my example in main.cpp@
#include <QtGui>int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(320, 240);
window.setWindowTitle(QApplication::translate("childwidget", "Child widget"));
window.show();
QPushButton *button = new QPushButton(
QApplication::translate("childwidget", "Press me"), &window);
button->move(100, 100);
button->show();
return app.exec();
}
@mainwindow.cpp
@
#include "mainwindow.h"#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}@
mainwindow.h
@
#ifndef MAINWINDOW_H#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H@
when i run above code it works perfectly but when i change this line
@
QPushButton *button = new QPushButton(QApplication::translate("childwidget", "Press me"), &window);
@to
@
QPushButton *button = new QPushButton(QApplication::translate("childwidget", "ok"), &window);
@this it fails to run. then when i change it again to "Press me" again displays the error. it only runs when i open new file and create it from start and run it again then it works but it creates problem when i modify there.
here is the error in build issues tab
@:: error: [debug\ChildWindow2.exe] Error 1@
this is in compile output tab
@
Running build steps for project ChildWindow2...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directoryC:/Qt/2010.04/examples/ChildWindow2-build-desktop' C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory
C:/Qt/2010.04/examples/ChildWindow2-build-desktop'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"....\qt\include\QtCore" -I"....\qt\include\QtGui" -I"....\qt\include" -I"....\qt\include\ActiveQt" -I"debug" -I"." -I"..\ChildWindow2" -I"." -I"....\qt\mkspecs\win32-g++" -o debug\main.o ..\ChildWindow2\main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\ChildWindow2.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\Qt\2010.04\qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directoryC:/Qt/2010.04/examples/ChildWindow2-build-desktop' mingw32-make: Leaving directory
C:/Qt/2010.04/examples/ChildWindow2-build-desktop'
mingw32-make[1]: *** [debug\ChildWindow2.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project ChildWindow2 (target: Desktop)
When executing build step 'Make'
@ -
You did put preprocessor commands and code into the same line again:-)
See "here":http://developer.qt.nokia.com/forums/viewthread/241/ for why that does not work.
-
it is not an issue because i put preprocessor commands and code on different line. It changed when i copy and paste it here. it is not an issue. problem is somewhere else.
and also why my Qt creator does not display exact errors. e.g, when i write C++ code or other language code in their respective IDEs and when i make mistakes then it displays the exact errors filename line number etc. but Qt creator doesnt for me. What can be the problem?
-
Well, Creator does display all the errors contained in your compile output... and (at least in the part you pasted here) there are none, except for the one that is in the build issues tab. Creator is no compiler, it can only work with what compiler and buildsystem provide!
It would be very useful, if you would not change the code when pasting it. Please make sure that the pasted code compiles (or displays exactly the same issue you are asking about) when asking questions. It is rather hard to guess at issues based on mangled code!
Anyway: Syntactically the code seems to be correct (otherwise you would have gcc errors in your compile output). That leaves your buildsystem: What is in your .pro-file? Make errors are often a sign for issues there.
-
when i paste code and do not change it runs fine. but when i want to make change like above then it fails to run and displays all those things above. and then when i change it to original code again then it still does not work which for the first time it worked
-
All the 01 lines in your pasted code are wrong (either several preprocessor commands on one line or preprocessor commands and code in one line), so you should have some trouble if that is really the code you are running. Try fixing that.
If your code is different from what you pasted then please paste the real code and include the .pro file.
-
ok i edit all 01 lines and here is my .pro file
@
#-------------------------------------------------Project created by QtCreator 2010-07-12T15:54:51
#-------------------------------------------------
QT += core gui
TARGET = untitled3
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
@