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. Hello, don't meant to bug anybody again, =/. QDockWidget not doing what I expected it to do.
Forum Updated to NodeBB v4.3 + New Features

Hello, don't meant to bug anybody again, =/. QDockWidget not doing what I expected it to do.

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 4.2k 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.
  • R Offline
    R Offline
    RichardM198030
    wrote on last edited by
    #1

    Hello, I was trying to get my QDockWidget WIdget to hide and show when a user clicks the Checkbox, but it didn't appear to be doing what I expected it to do.

    I have included a link to my sources. Whoops, forgot to add more, it does compile, but it appears to be showing and not hiding.

    http://pastebin.com/ZXMsc9QE

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      In your constructor you use :

      @    if (showdckWidgetChkBox->isChecked()) {
              showdckWidgetChkBox->show();
          } else {
              showdckWidgetChkBox->hide();
          }@

      This means that only once the hide or show will work.

      On the same place you should use a connect :
      Use the checkbox as sender and the dockwidget uses a slot to act on that.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        example code
        @connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setHidden(bool)));@

        of course you should adapt the widget names to your needs.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RichardM198030
          wrote on last edited by
          #4

          [quote author="Eddy" date="1310895955"]example code
          @connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setHidden(bool)));@

          of course you should adapt the widget names to your needs.[/quote]

          Okay, thanks, that worked, but another bug, =/. But when it is checked, it's hidden, =/.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            loladiro
            wrote on last edited by
            #5

            @
            connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setVisible(bool)));
            @

            1 Reply Last reply
            0
            • R Offline
              R Offline
              RichardM198030
              wrote on last edited by
              #6

              [quote author="loladiro" date="1310898744"]@
              connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setVisible(bool)));
              @[/quote]

              Heh, awesome, thanks for the help, that worked, sorry, I should have known this, as much as I've been studying Qt, you'd think, by now, after 3 or more months, I know it all, hahaha.. Honestly, I don't, it's due to my laziness and not doing anything other than Menus and QTextEdits, decided to try something different for a change, and so far, heck yeah, =). Thanks again.

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                if you want to learn about signals and slots :

                "this is a must have read :":http://doc.qt.nokia.com/4.7/signalsandslots.html

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RichardM198030
                  wrote on last edited by
                  #8

                  [quote author="Eddy" date="1310900176"]if you want to learn about signals and slots :

                  "this is a must have read :":http://doc.qt.nokia.com/4.7/signalsandslots.html[/quote]

                  Looks to me like almost all things in Qt requires Sigs/Slots..

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #9

                    Hi Richard,

                    not all but it is very usefull and ion many places needed :-)
                    Especially for UI inetraction or for asynchronous things.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      RichardM198030
                      wrote on last edited by
                      #10

                      [quote author="Gerolf" date="1310903850"]Hi Richard,

                      not all but it is very usefull and ion many places needed :-)
                      Especially for UI inetraction or for asynchronous things.[/quote]

                      Heh, have to write more codes it appears, when a user clicks the X, the Checkbox doesn't automatically Uncheck. Also, having an issue with getting the DockWidget to stay small, I did get it so it stays at bottom, but now it's onto learning how to make it resize, tried the dckwidget->setGeometry(0, 150, 1024, 100); but it didn't appear to do anything, =/. It still stays just as large as the parent window.

                      1 Reply Last reply
                      0
                      • EddyE Offline
                        EddyE Offline
                        Eddy
                        wrote on last edited by
                        #11

                        You need to emit a signal from the dockwidget and connect it with a slot of the checkbox.

                        Qt Certified Specialist
                        www.edalsolutions.be

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          RichardM198030
                          wrote on last edited by
                          #12

                          [quote author="Eddy" date="1310905367"]You need to emit a signal from the dockwidget and connect it with a slot of the checkbox.[/quote]

                          Argh, too sleepy to understand now, ahahaha.. That just went over my head, later I'll get to it, LOL..

                          1 Reply Last reply
                          0
                          • EddyE Offline
                            EddyE Offline
                            Eddy
                            wrote on last edited by
                            #13

                            It's not that difficult.
                            Hint : Use the same approach as before. Look for a signal and slot with a bool argument.

                            Qt Certified Specialist
                            www.edalsolutions.be

                            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