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. Qt not being installed on win XP and question about QObject::connect() function.
Forum Updated to NodeBB v4.3 + New Features

Qt not being installed on win XP and question about QObject::connect() function.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 2.6k 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.
  • S Offline
    S Offline
    Sahil
    wrote on last edited by
    #1

    I'm newbie here so sorry if I post it in wrong place. I know c++ but not visual. I used to make Qt style sheets and developed interest in programming. I have worked with Qt style sheets and I remember name of almost every function but my logical programming isn't good enough. My slow internet finally managed to download huge Qt SDK and I have two following problems.

    First,
    I tried installing Qt on my school PC which is as old as hills having window XP and 512 MB ram. I tried installing Qt thre but it said "Setup not configured properly" where it worked fine on my pc. I have win 7, 2 GB ram. Is there any way to install it there. We use code::block at school. Can I link Qt with code::block?

    Second,
    I have problem with following code.
    Here is what I wrote
    @
    #include <QtGui>

    int main(int argv, char **args)
    {
    QApplication app(argv, args);

    QTextEdit textEdit;
    QPushButton but("Quit");

    QObject::connect(&but, SIGNAL(clicked()), app, SLOT(quit()));

    QVBoxLayout lay;
    lay.addWidget(&textEdit);
    lay.addWidget(&but);

    QWidget win;
    win.setLayout(&lay);
    win.show();

    return app.exec();
    }
    @
    It works fine when I copy paste from tutorial. But when I rewrote it myself, it didn't work. I tried many times but no solution.

    Here is original tutorial code from Qt documentation.
    @
    #include <QtGui>

    int main(int argv, char **args)
    {
    QApplication app(argv, args);

    QTextEdit textEdit;
    QPushButton quitButton("Quit");

    QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));

    QVBoxLayout layout;
    layout.addWidget(&textEdit);
    layout.addWidget(&quitButton);
    QWidget window;
    window.setLayout(&layout);

    window.show();

    return app.exec();
    }
    @

    I got this error
    EDIT:
    I replaced the code as guziemic said but still getting this error :(
    H:\programs\Qt_Test-build-desktop-Qt_4_8_1_for_Desktop_-_MSVC2010__Qt_SDK__Release..\Qt_Test\main.cpp:31: error: C2665: 'QObject::connect' : none of the 3 overloads could convert all the argument types
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qobject.h(204): could be 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qobject.h(217): or 'bool QObject::connect(const QObject *,const QMetaMethod &,const QObject *,const QMetaMethod &,Qt::ConnectionType)'
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qobject.h(231): or 'bool QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const'
    while trying to match the argument list '(QPushButton *, const char [11], QApplication, const char [8])'

    Thank you.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      guziemic
      wrote on last edited by
      #2

      Hi,

      It is better if you put code with code markers '@' '@' then it is more readable.

      Regarding error you did not define to which slot and signal you would like to connect. I assume that when you click on some button then application should be closed. Then code should look following

      Should be:
      @
      QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit())));
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Note the missing parenthesis in your connect call in the signal parameter.

        Moderators note:
        It is much more useful to ask separate questions in separate topics. It also allows to move the question to the right forum. Also, the Lounge forum where you posted is not meant for on-topic Qt support questions. It is more for general chat and meta-discussions.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          webmaster.skelton
          wrote on last edited by
          #4

          @QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit())));@

          Should probably be

          @QObject::connect(&quitButton, SIGNAL(clicked()), app, SLOT(quit())));@

          I am assuming you are wanting to refer QApplication Object which you have named as "app" but are calling it
          "qApp" in your connect statement. Unless there is something I am missing.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            twsimpson
            wrote on last edited by
            #5

            "qApp":http://qt-project.org/doc/qt-4.8/qapplication.html#qApp is a macro that give a pointer to the global QApplication instance. And as connnect() requires a pointer to a QObject, qApp works. Or you could take the address of your app variable:
            @QObject::connect(&quitButton, SIGNAL(clicked()), &app, SLOT(quit()));@

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sahil
              wrote on last edited by
              #6

              Okay thanks guys '&app' worked. It was my mistake :P

              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