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. How to create 'x' CLOSE/ EXIT button on the dialog Box?
Forum Updated to NodeBB v4.3 + New Features

How to create 'x' CLOSE/ EXIT button on the dialog Box?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.8k 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.
  • B Offline
    B Offline
    buxi07
    wrote on 8 Apr 2012, 18:42 last edited by
    #1

    Hey! I am Burhan
    I am working on a periodic table in Qt c++. Belle Symbian.
    The theme is when you click on the button of an element the properties of the respective element appears in the dialog and the dialog contains information about the element and the back/ close button.
    Before working on the periodic table and design all buttons i want to test a one first.
    I have stuck. i don't know how to create a 'x' close/ back button on the dialog.

    CAN anyone PLEASE tell me how to create a close button on the dialog.????? :( I am just a starter so please suggest me the easy way.
    Thanks. Awaiting for your reply.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jeroentjehome
      wrote on 8 Apr 2012, 18:55 last edited by
      #2

      If you use the static function of a QMessageBox::information you can enter all the stuff you want. Qt will handle the close 'x' automatic and if you want you can add the normal ok/cancel buttons if needed using the StandardButton enum. Just check out the QMessageBox for more information. If you set the parent with 'this' all other functions will be halted until the messagebox is closed. If that isn't want you want you are able to set the setModal to alter it so multiple messageboxen can be opened.
      Greetz and have fun!

      Greetz, Jeroen

      1 Reply Last reply
      0
      • B Offline
        B Offline
        buxi07
        wrote on 8 Apr 2012, 19:16 last edited by
        #3

        Thanks buddy for the suggestion. I have to do it through dialog box.
        @#include "hydrogen.h"
        #include "ui_hydrogen.h"
        #include <QLabel>
        #include <QtGui>
        #include <QtCore>

        Hydrogen::Hydrogen(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Hydrogen)
        {
        ui->setupUi(this);
        Hydrogen :: hydinfo();
        }

        Hydrogen::~Hydrogen()
        {
        delete ui;
        }
        void Hydrogen :: hydinfo(void)
        {
        QGridLayout *layout = new QGridLayout;
        QLabel *name = new QLabel ("Name");
        layout->addWidget(name, 0, 0);

        QLabel *sym = new QLabel ("Symbol");
        layout->addWidget(sym, 1,0);
        QLabel *sym2 = new QLabel ("H");
        layout->addWidget(sym2, 1,1);

        QLabel *chemser = new QLabel ("Chemical Series");
        layout->addWidget(chemser, 2,0);
        QLabel *chemser2 = new QLabel ("Non-Metals");
        layout->addWidget(chemser2, 2,1);
        
        Hydrogen :: setLayout(layout);
        Hydrogen :: show();
        

        }
        @
        Like this... but when i deploy it on C7 it doesn't show any close button :/

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 8 Apr 2012, 20:23 last edited by
          #4

          if you want to add a "back" button on the bottom of the dialog: just add
          @
          QPushButton *backButton= new QPushButton;
          backButton->setText("Back");
          connect (backButton,SIGNAL(clicked()),this,SLOT(hide()));
          layout->addWidget(backButton,3,0,1,2);
          @
          just before the Hydrogen :: setLayout(layout); line in the hydinfo() method

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • B Offline
            B Offline
            buxi07
            wrote on 8 Apr 2012, 21:06 last edited by
            #5

            @VRonin: Done Successfully!
            Thanks in tons =)

            1 Reply Last reply
            0

            1/5

            8 Apr 2012, 18:42

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved