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. How do I "split the window"?
Forum Updated to NodeBB v4.3 + New Features

How do I "split the window"?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 416 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    This post is about same issue I have posted elsewhere, but it is NOT a dupe....

    I just need some fresh , different idea how to solve

    I have "main window " ( QMainWindow) where

    setCentralWidget(m_console);

    is my current, final "view" I/O "window" ( plain text class )

    and it does the job accessing the serial port....

    What I want is to have ANOTHER way to access the serial port - ideally showing BOTH the original console "view" and the new means to access same serial port.

    I have replaced the "console" with MDIArea , however it is getting too convoluted to have the original "console" and the
    new access as TWO subwindow of the MDIArea....

    In not so technical description - how do I "split" the current I//O ( console ) "window" and add another "view" of same serial port.

    So currently I have
    (main) MDI class
    real subwindow - QMainWindow ( access to serial ports)
    console class as I/O

    what I like to have

    (main) MDI class
    rear subwindow - QMainWindow ( access to serial ports)

    intermediate way / class - split final view
    original view - console class as I/O
    new , additional view - serial control class as I/O

    //! [0]
    MainWindow_Serial::MainWindow_Serial(QWidget *parent) :
        QMainWindow(parent),
        m_ui(new Ui::MainWindow_Serial),
        m_status(new QLabel),
        m_console(new Console),
        m_settings(new SettingsDialog),
    //! [1]
        m_serial(new QSerialPort(this))
    //! [1]
    {
    //! [0]
        m_ui->setupUi(this);
        m_console->setEnabled(false);
        setCentralWidget(m_console);
    '
    ***replaced with  QMainWindow -> QMDIArea*** 
    
        m_ui->actionConnect->setEnabled(true);
        m_ui->actionDisconnect->setEnabled(false);
        m_ui->actionQuit->setEnabled(true);
        m_ui->actionConfigure->setEnabled(true);
    
        m_ui->statusBar->addWidget(m_status);
    
        initActionsConnections();
    
        connect(m_serial, &QSerialPort::errorOccurred, this, &MainWindow_Serial::handleError);
    
    //! [2]
        connect(m_serial, &QSerialPort::readyRead, this, &MainWindow_Serial::readData);
    //! [2]
        connect(m_console, &Console::getData, this, &MainWindow_Serial::writeData);
    //! [3]
    }
    
    Gojir4G 1 Reply Last reply
    0
    • A Anonymous_Banned275

      This post is about same issue I have posted elsewhere, but it is NOT a dupe....

      I just need some fresh , different idea how to solve

      I have "main window " ( QMainWindow) where

      setCentralWidget(m_console);

      is my current, final "view" I/O "window" ( plain text class )

      and it does the job accessing the serial port....

      What I want is to have ANOTHER way to access the serial port - ideally showing BOTH the original console "view" and the new means to access same serial port.

      I have replaced the "console" with MDIArea , however it is getting too convoluted to have the original "console" and the
      new access as TWO subwindow of the MDIArea....

      In not so technical description - how do I "split" the current I//O ( console ) "window" and add another "view" of same serial port.

      So currently I have
      (main) MDI class
      real subwindow - QMainWindow ( access to serial ports)
      console class as I/O

      what I like to have

      (main) MDI class
      rear subwindow - QMainWindow ( access to serial ports)

      intermediate way / class - split final view
      original view - console class as I/O
      new , additional view - serial control class as I/O

      //! [0]
      MainWindow_Serial::MainWindow_Serial(QWidget *parent) :
          QMainWindow(parent),
          m_ui(new Ui::MainWindow_Serial),
          m_status(new QLabel),
          m_console(new Console),
          m_settings(new SettingsDialog),
      //! [1]
          m_serial(new QSerialPort(this))
      //! [1]
      {
      //! [0]
          m_ui->setupUi(this);
          m_console->setEnabled(false);
          setCentralWidget(m_console);
      '
      ***replaced with  QMainWindow -> QMDIArea*** 
      
          m_ui->actionConnect->setEnabled(true);
          m_ui->actionDisconnect->setEnabled(false);
          m_ui->actionQuit->setEnabled(true);
          m_ui->actionConfigure->setEnabled(true);
      
          m_ui->statusBar->addWidget(m_status);
      
          initActionsConnections();
      
          connect(m_serial, &QSerialPort::errorOccurred, this, &MainWindow_Serial::handleError);
      
      //! [2]
          connect(m_serial, &QSerialPort::readyRead, this, &MainWindow_Serial::readData);
      //! [2]
          connect(m_console, &Console::getData, this, &MainWindow_Serial::writeData);
      //! [3]
      }
      
      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      Hi @AnneRanch,

      Personally I like to use QDockWidget for this. So you can easily move, resize, hide/show your view according to your needs.

      Something like that

      QDockWidget *dock = new QDockWidget(tr("Serial"), this);
      dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
      m_serialCtrl = SerialControlWidget()
      dock->setWidget(serialCtrl);
      this->addDockWidget(Qt::RightDockWidgetArea, dock);
      // Optional, allow to show/hide view from the menu and/or toolbar
      viewMenu->addAction(dock->toggleViewAction());
      

      Another possibility would be to use a QSplitter as main widget, and set your two widgets console and serial as "childs".

      //setCentralWidget(m_console);
      QSplitter *splitter = new QSplitter(Qt::Horizontal);
      splitter.addWidget(m_console);
      splitter.addWidget(m_serialCtr);
      setCentralWidget(m_serialCtrl);
      
      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