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. QMessageBox with QSpinBox
Forum Updated to NodeBB v4.3 + New Features

QMessageBox with QSpinBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.5k Views 2 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.
  • michalt38M Offline
    michalt38M Offline
    michalt38
    wrote on last edited by
    #1

    Hello,
    is it possible to put in QMessageBox a QSpinBox?

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

      Hi! No, that's not possible. But you can make your own "message box" by creating a custom widget that inherits from QDialog.

      1 Reply Last reply
      5
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        While it's possible to do using the property based version,
        it often do not work as you
        want and as @Wieland says, the best option is to make your own.

        However, for fun/test code, you can do

        
        void MainWindow::on_pushButton_released() {
          QMessageBox msgBox;
          QSpinBox* b = new QSpinBox();
          if (msgBox.layout())
            msgBox.layout()->addWidget(b);
          msgBox.setText("The document has been modified.");
          msgBox.exec();
        }
        
        

        and get

        alt text

        But its not useful in production code as they might change the QMessagebox
        and your code might suddenly stop working so create a new one based on QDialog is the way to go.
        Also as you can see, its comes after OK and might look even stranger if u set more of the flags/options.

        1 Reply Last reply
        4

        • Login

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