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. QToolBar not functioning properly
Forum Updated to NodeBB v4.3 + New Features

QToolBar not functioning properly

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.5k 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.
  • 8 Offline
    8 Offline
    8Wallace8
    wrote on last edited by
    #1

    I'm having a problem getting my toolbar to show it's border or even be set as movable. I have four different instances, located on my app, that I'm splitting using QSplitter's and each one has a toolbar.I'm unable to solve the problem, I'm new to Qt, so any help will be really appreciated.

    My Code:

    @
    QWidget *view = new QTextEdit(this);
    QVBoxLayout *vbox = new QVBoxLayout(this);

    fileToolBar = new QToolBar(this);
    fileToolBar->addAction("file");
    fileToolBar->setMovable(true);

    vbox->addWidget(fileToolBar);
    vbox->addWidget(view);
    vbox->setContentsMargins(0,0,0,0);
    vbox->setSpacing(0);
    setLayout(vbox);
    @

    Here is a picture of what my app looks like.
    I got the idea from this "link":http://qt-project.org/forums/viewthread/3647, but my app doesn't look the same.

    !http://img15.imageshack.us/img15/3606/7onj.png!

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Who is the parent of your setLayout function? This setLayout is done on a QWidget?

      Greetz, Jeroen

      1 Reply Last reply
      0
      • 8 Offline
        8 Offline
        8Wallace8
        wrote on last edited by
        #3

        header file: "pane.h"

        @
        class Pane : public QWidget
        {
        Q_OBJECT

        public:
        Pane(QWidget* parent = 0);

        private:
        void createActions();
        void createToolBars();
        QAction *newAction;
        QToolBar *fileToolBar;
        };

        @

        Source File: "pane.cpp"
        createToolBars() is called by Pane::Pane(QWidget* parent)

        @
        void Pane::createToolBars()
        {

        QWidget *view = new QTextEdit(this);
        QVBoxLayout *vbox = new QVBoxLayout(this);
        
        fileToolBar = new QToolBar(this);
        fileToolBar->addAction("file");
        fileToolBar->setMovable(true);
        
        vbox->addWidget(fileToolBar);
        vbox->addWidget(view);
        vbox->setContentsMargins(0,0,0,0);
        vbox->setSpacing(0);
        setLayout(vbox);    
        

        }@

        I'm extremely new to Qt and not sure if it is a QWidget or Q_OBJECT.

        1 Reply Last reply
        0
        • 8 Offline
          8 Offline
          8Wallace8
          wrote on last edited by
          #4

          I create the instances in QMainWindow
          @
          MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)

          {
          QWidget *wnd = new QWidget;
          QWidget *container_1 = new QWidget;
          QWidget *container_2 = new QWidget;

          QHBoxLayout *h_layout1 = new QHBoxLayout;
          QHBoxLayout *h_layout2 = new QHBoxLayout;
          QVBoxLayout *v_layout3 = new QVBoxLayout;
          
          QSplitter *split1 = new QSplitter;
          QSplitter *split2 = new QSplitter;
          QSplitter *split3 = new QSplitter;
          
          Pane *p1 = new Pane;
          Pane *p2 = new Pane;
          Pane *p3 = new Pane;
          Pane *p4 = new Pane;
          
          split1->addWidget(p1);
          split1->addWidget(p2);
          
          split2->addWidget(p3);
          split2->addWidget(p4);
          
          h_layout1->addWidget(split1);
          h_layout2->addWidget(split2);
          
          container_1->setLayout(h_layout1);
          container_2->setLayout(h_layout2);
          
          split3->setOrientation(Qt::Vertical);
          split3->addWidget(container_1);
          split3->addWidget(container_2);
          
          v_layout3->addWidget(split3);
          wnd->setLayout(v_layout3);
          
          setCentralWidget(wnd);
          

          }
          @

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tilsitt
            wrote on last edited by
            #5

            Hi,

            your toolbar can't be movable. This functionality can only be used with a toolbar in a QMainWindow (using "QMainWindow::addToolBar()":http://qt-project.org/doc/qt-5.1/qtwidgets/qmainwindow.html#addToolBar, see the documentation of the "movable property":http://qt-project.org/doc/qt-5.1/qtwidgets/qtoolbar.html#movable-prop).

            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