Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create window help
Forum Updated to NodeBB v4.3 + New Features

Create window help

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 6.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doforumda
    wrote on last edited by
    #1

    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(&#41;;
    }
    @

    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 directory C:/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 directory C:/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'
    @

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doforumda
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            doforumda
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                doforumda
                wrote on last edited by
                #7

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

                SOURCES += main.cpp
                mainwindow.cpp

                HEADERS += mainwindow.h

                FORMS += mainwindow.ui

                @

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved