Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:38:33+00:00 2026-05-16T22:38:33+00:00

QString QInputDialog::getText ( QWidget * parent, const QString & title, const QString & label,

  • 0
QString QInputDialog::getText ( QWidget * parent, const QString & title, 
    const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal,
    const QString & text = QString(), bool * ok = 0, 
    Qt::WindowFlags flags = 0 )   [static] 

This function is defined to call a dialog get and return the text which will be inserted in a QLine edit. So I want to create a getData static method that returnes a data structure (say QPair) and work right like QInputDialog::getText(). I tried but I couldn’t do that. How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:38:34+00:00Added an answer on May 16, 2026 at 10:38 pm

    I have done it, but I post for people that need this. Here is an axample of a dialog box, which is for resizing an image. To be more precise it is for representing user the current size of an image and provide him/her with an interface to change the size and get the new size with a QPair.

    class ResizeImageDialog : public QDialog
    {
        Q_OBJECT
    
    double                   m_ratio;
    
    QLabel                  *m_widthLabel;
    QLabel                  *m_hightLabel;
    QDoubleSpinBox          *m_widthSpinBox;
    QDoubleSpinBox          *m_hightSpinBox;
    QCheckBox               *m_keepRatioCheckBox;
    
    QPushButton             *m_okButton;
    QPushButton             *m_cancelButton;
    
    QHBoxLayout             *m_widthLayout;
    QHBoxLayout             *m_hightLayout;
    QHBoxLayout             *m_buttonLayout;
    QVBoxLayout             *m_generalLayout;
    
    private slots:
        void widthChanged(double width);
        void hightChanged(double hight);
    
    public:
        ResizeImageDialog(QWidget * parent = 0, double imageWidth = 100.0, double imageHight = 100.0):QDialog(parent)
        {
        m_widthLabel = new QLabel("Image width");
        m_hightLabel = new QLabel("Image hight");
    
        m_widthSpinBox = new QDoubleSpinBox;
        m_widthSpinBox->setMaximum(1500);
        m_widthSpinBox->setValue(imageWidth);
        connect(m_widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(widthChanged(double)));
    
    
        m_hightSpinBox = new QDoubleSpinBox;
        m_hightSpinBox->setMaximum(1500);
        m_hightSpinBox->setValue(imageHight);
        connect(m_hightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(hightChanged(double)));
    
        m_ratio = imageWidth/imageHight;
    
    
        m_keepRatioCheckBox = new QCheckBox("Keep ratio",this);
        m_keepRatioCheckBox->setChecked(true);
    
    
        m_widthLayout = new QHBoxLayout;
        m_widthLayout->addWidget(m_widthLabel);
        m_widthLayout->addWidget(m_widthSpinBox);
    
        m_hightLayout  = new QHBoxLayout;
        m_hightLayout->addWidget(m_hightLabel);
        m_hightLayout->addWidget(m_hightSpinBox);
    
        m_okButton = new QPushButton("OK");
        connect(m_okButton, SIGNAL(clicked()), this, SLOT(accept()));
    
        m_cancelButton = new QPushButton("Cancel");
        connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    
        m_buttonLayout = new QHBoxLayout;
        m_buttonLayout->addStretch();
        m_buttonLayout->addWidget(m_okButton);
        m_buttonLayout->addWidget(m_cancelButton);
    
        m_generalLayout = new QVBoxLayout;
        m_generalLayout->addLayout(m_widthLayout);
        m_generalLayout->addLayout(m_hightLayout);
        m_generalLayout->addWidget(m_keepRatioCheckBox);
        m_generalLayout->addLayout(m_buttonLayout);
        setLayout(m_generalLayout);
    
        setMaximumSize(300, 300);
        setModal(true);
        //resize(670,630);
        setWindowTitle(tr("Resize Image"));
        setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    }
    
    static QPair<double, double> getNewSize(QWidget * parent = 0, double imageWidth = 100.0, double imageHight = 100.0)
    {
        ResizeImageDialog dlg(parent, imageWidth, imageHight);
        dlg.exec();
    
    
    
        QPair<double, double> size;
        size.first = dlg.m_widthSpinBox->value();
        size.second = dlg.m_hightSpinBox->value();
        return size;
    }
    };
    

    And now you can do this:

     QPair<double, double> size = ResizeImageDialog::getNewSize(this, newImageFormat.width(), newImageFormat.height());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.