Qt Button Create

  • Hello everyone.

    I am having one trouble. I try to create PushButton.

    In file CFrameWnd.cpp
    @void SukurtiAnt()
    QPushButton button = new QPushButton(this);
    { background-color: rgb(50,205,50) }");

    In file CFrameWnd.h
    @void SukurtiAnti() @

    And main.cpp

    @int main(int argc, char *argv[])
    QApplication a(argc, argv);
    CFrameWnd w;
    return a.exec();

    When i execute program i just get blank screen with no button created. I think that problem is in main.cpp but dunno how to fix it. Any ideas ? Thanks, in advance.

    Edit: fixed the code lines. Please only use one @ tag before, and one at the end of a code block. You don't need to start every line with a code tag; Andre

  • Moderators

    Is your constructor for CFrameWnd calling SukurtiAnti()?

  • I am so new at qt, that I don't know how to look if it is calling constructor or not....

  • I think there is my constructor

    @CFrameWnd::CFrameWnd(QWidget *parent) :
    ui(new Ui::CFrameWnd)



  • Heh, i found. mlong was right :) this function was not mentioned in constructor :) Thanks!!!!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.