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 Button Create
Qt 6.11 is out! See what's new in the release blog

Qt Button Create

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      Is your constructor for CFrameWnd calling SukurtiAnti()?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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()));
          

          }@

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

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

            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