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. QDialog showing as empty?
Forum Updated to NodeBB v4.3 + New Features

QDialog showing as empty?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.4k Views
  • 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.
  • Jamie_EdwardsJ Offline
    Jamie_EdwardsJ Offline
    Jamie_Edwards
    wrote on last edited by
    #1

    Hi guys,

    So I've tried creating a QDialog but have run into a problem that I cannot figure out.

    So I know that the dialog window is being created and built, but upon calling the

    show();
    

    function, the window seems to end up being empty. The code is as follows:

    This function works perfectly:

    void Lantease::on_help_aboutLantease_clicked() {
        Ui::AboutLantease win(new QDialog());
        win.show();
        win.exec();
    }
    

    These seem like they work appropriately:

    Ui::AboutLantease::AboutLantease(QDialog *parent) :
    QDialog(parent) {
        setupUi();
    }
    
    void Ui::AboutLantease::setupUi() {
        if(parent->objectName().isEmpty()) {
            parent->setObjectName(QStringLiteral("dialog_aboutLantease"));
        }
        parent->resize(800, 600);
    
        createWidgets();
        createLayouts();
        enableDebugLines(true);
        buildAboutDialog();
    
        retranslateUi();
    
        std::cout << "Was enabled" << std::endl;
    }
    

    As I previously stated, the above works appropriately and I know this because I put cout calls in each function, all of which were outputted.

    However, when the QDialog window is shown, it is completely empty AND there is no title, despite calling

    setWindowTitle();
    

    in retranslateUi().

    Any ideas?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Efreen
      wrote on last edited by Efreen
      #2

      I suppose that AboutLantease inherits from QDialog. In this case don't use parent (only for initialization in constructor (...(QDialog *parent) :
      QDialog(parent)...)).

      Jamie_EdwardsJ 1 Reply Last reply
      2
      • E Efreen

        I suppose that AboutLantease inherits from QDialog. In this case don't use parent (only for initialization in constructor (...(QDialog *parent) :
        QDialog(parent)...)).

        Jamie_EdwardsJ Offline
        Jamie_EdwardsJ Offline
        Jamie_Edwards
        wrote on last edited by
        #3

        @Efreen do I just use "this" after that?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Efreen
          wrote on last edited by
          #4

          "This" Instead of parent or nothing, don't call to parent.

          I mean:

          Ui::AboutLantease::AboutLantease(QDialog *parent) :
          QDialog(parent) {
              setupUi();
          }
          
          void Ui::AboutLantease::setupUi() {
              if(this->objectName().isEmpty()) { //or objectName().isEmpty()
                  this->setObjectName(QStringLiteral("dialog_aboutLantease")); //or setObjectName(QStringLiteral
              }
              this->resize(800, 600); //or resize(800, 600)
          
              createWidgets();
              createLayouts();
              enableDebugLines(true);
              buildAboutDialog();
          
              retranslateUi();
          
              std::cout << "Was enabled" << std::endl;
          }
          
          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