Results 1 to 6 of 6

Thread: qobject connect questions

  1. #1
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default qobject connect questions

    Hey, I have two questions
    1)
    I have uig.qpbTest (inside a QDesigner h file, uig is a class of namespace of h file, a qpushbutton*), and when i use connect:

    connect(uig.qpbTest, SIGNAL(clicked()), this, SLOT(procTest()));

    It doesn't work, procTest is never activated. Why can't I connect this object?
    procTest() is a private slot and is moc'ed.

    2)
    When I try to use a private slot inside a function, it won't launch it:
    int CMain:o_one(){
    doSomething(1); // doSomething is a PRIVATE SLOT in CMain.
    }
    It won't work this way, I dont know why.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qobject connect questions

    Posting the code would have been really useful.

    1) Connect often outputs messages to the console( stderr actually ) when something goes wrong. Look and see if you can find something there.
    Have you added Q_OBJECT yo your class definition?

    2)It really doesn't matter that it is private, especially if you call it within the same class.
    Use qDebug in all the problematic places if you can't debug the app properly.

    But as I said, without some sources, I can't really tell you much. Otherwise, the code you posted seems OK.

    Regards
    Last edited by marcel; 20th May 2007 at 00:23.

  3. #3
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qobject connect questions

    1) "this" has Q_OBJECt and objects do work well, its just this single connect that doesn't work. the uig stuff comes from output of a ui file that QDesigner makes, (uic.exe) and so i didnt feel like posting that.
    And I just did Ui::uiClass uig;
    2) doSomething(); works in a button I have in the Main class... but when I directly access it inthis way without a "connect"... it doesn't activate. I'm not sure what other code i can post, the code i post would be unrelated.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qobject connect questions

    It makes no sense doSomething not being called, even if it is a slot. A slot is basically a function and is nothing incorrect if you call it manually.
    Are you absolutely sure that the function doesn't called at all, or does get called but just doesn't do anything?

    Also, it may be CMain:: do_one(). How do you call this?

  5. #5
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qobject connect questions

    Ok i will take a better look you're probably right.

  6. #6
    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: qobject connect questions

    How do you know the slot doesn't get called?

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.