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);
ui->gridLayout->addWidget(button);
button->setSizeIncrement(20,20);
button->setStyleSheet(" { background-color: rgb(50,205,50) }");
ui->gridLayout->setAlignment(button,Qt::AlignCenter);
}
@In file CFrameWnd.h
@void SukurtiAnti() @And main.cpp
@int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CFrameWnd w;
w.show();
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
-
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) :
QMainWindow(parent),
ui(new Ui::CFrameWnd)
{
ui->setupUi(this);QStatusBar::connect(ui->actionPABAIGA,SIGNAL(activated()),this,SLOT(on_actionPABAIGA_triggered()));
}@
-
Heh, i found. mlong was right :) this function was not mentioned in constructor :) Thanks!!!!