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. DISPLAY ISSUE - PROMOTING TO MAINWINDOW
Forum Updated to NodeBB v4.3 + New Features

DISPLAY ISSUE - PROMOTING TO MAINWINDOW

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 750 Views 3 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.
  • K Kailash

    Thankyou for your quick response.

    Similar to this radar display we have 5 other displays designed and working when we run as pop up dialog.
    But we want to integrate all displays in mainwindow and display in single screen, however we would like to keep the UI and cpp as seperate for each display widgets.

    As you suggested, if i make my radar display as central widget then i feel i can't show other displays in the mainwindow. So please suggest a method to display all my custom widget into mainwindow without adding my code into mainwindow.

    I have tried the following to display my widget in mainwindow, (Please find the code for radar display dialog)

    #include "display_radar.h"
    #include "ui_display_radar.h"
    #include <QPainter>
    #include <QDebug>
    #include <QtMath>
    #include <Radar_Headers.h>
    
    Display_Radar::Display_Radar(QWidget *parent, QRectF *in_Widget_Rect, QGroupBox *Disp_Widget) :
        QWidget(parent),
        ui(new Ui::Display_Radar)
    {
        ui->setupUi(this);
        d_Max_ScreenRange = RADAR_STATIC_ARC_MAX_RANGE;
        Find_Display_Area(&m_RectangleArea, ui->groupBox_Radar_Display);
        qDebug()<<"Rect Width"<<m_RectangleArea.width();
        qDebug()<<"Rect Height"<<m_RectangleArea.height();
        qDebug()<<"Coord "<<m_RectangleArea.x()<<m_RectangleArea.y();;
    }
    
    Display_Radar::~Display_Radar()
    {
        delete ui;
    }
    
    void Display_Radar::Draw_Radar_Static_Screen(QRectF *in_p_qRectF_Radar_Display_Area, QPainter *in_p_Painter, double *in_dp_Display_Percentage)
    {
        qreal d_changedWidth = 0, d_changedHeight = 0;
        qreal x = 0, y = 0;
        QColor Brush_Circle_color;
        QLineF LineF_Angle_DrawLine;
        QPen QPen_Radar_dotted_line;
    
        in_p_qRectF_Radar_Display_Area = &m_RectangleArea;
    
        memset(&Brush_Circle_color , 0, sizeof(Brush_Circle_color));
        memset(&LineF_Angle_DrawLine , 0, sizeof(LineF_Angle_DrawLine));
    
        Brush_Circle_color.setRgb(0,0,0,200);
    
        QPen_Radar_dotted_line.setWidth(2);
        QPen_Radar_dotted_line.setColor(QColor(6, 150, 11, 255));
        QPen_Radar_dotted_line.setStyle(Qt::DotLine);
    
        d_changedWidth = ((in_p_qRectF_Radar_Display_Area->width() * (*in_dp_Display_Percentage)) / 100);
        d_changedHeight = ((in_p_qRectF_Radar_Display_Area->height() * (*in_dp_Display_Percentage)) / 100);
    
        d_RectangleWidth = d_changedWidth;
    
        in_p_Painter->setPen(Qt::NoPen);
        in_p_Painter->setRenderHint(QPainter::Antialiasing);
        in_p_Painter->setBrush(Brush_Circle_color);
    
        x = in_p_qRectF_Radar_Display_Area->x() + (in_p_qRectF_Radar_Display_Area->width() - d_changedWidth) / 2;
        y = in_p_qRectF_Radar_Display_Area->y() + (in_p_qRectF_Radar_Display_Area->height() - d_changedHeight) / 2;
    
        in_p_Painter->drawPie(x, y, d_changedWidth, d_changedHeight, 0 * 16, 180 *16);
    
    }
    
    void Display_Radar::Find_Display_Area(QRectF *in_pq_RectF_Widget, QGroupBox *p_grpBox_Disp_Widget)
    {
        qreal d_x1 = 0.0, d_y1 = 0.0 ,d_x2 = 0.0,d_y2 = 0.0; // coordinates to set the points
        qreal dWidth = 0, dHeight = 0, dCorrection_x = 0, dCorrection_y = 0;
    
        d_x1 = p_grpBox_Disp_Widget->geometry().topLeft().x() + 55;
        d_y1 = p_grpBox_Disp_Widget->geometry().topLeft().y() + 65 ;
        d_x2 = p_grpBox_Disp_Widget->geometry().bottomRight().x();
        d_y2 = p_grpBox_Disp_Widget->geometry().bottomRight().y();
    
        dWidth = (d_x2 - d_x1) ;
        dHeight = (d_y2 - d_y1);
    
        if(dWidth > dHeight)
        {
            dCorrection_x = ((dWidth - dHeight) / 2);
        }
        else if(dHeight > dWidth)
        {
            dCorrection_y = ((dHeight - dWidth) / 2);
        }
    
        in_pq_RectF_Widget->setCoords((d_x1  + dCorrection_x), (d_y1 + dCorrection_y), (d_x2 - dCorrection_x), (d_y2 - dCorrection_y));
    }
    

    Attempt 1:

    1. I have derived this class from qwidget instead qdialog.
    2. In mainwindow added QGraphicsview and promoted my radar display class there.
    3. Got the very small display as shown in the attached image below

    Not working.png

    Attempt 2:

    1. I have derived this class from qwidget instead qdialog.
    2. Created the radar display class object in mainwindow and added into the stackwidget using insert_stacked_widget() function.
    3. When the application executes i am getting the following prints

    QPainter::begin: A paint device can only be painted by one painter at a time.

    On a side note, please don't use all upper cased title. In written language it is considered shouting and rude - Noted, thankyou.

    M Offline
    M Offline
    mpergand
    wrote on last edited by mpergand
    #5

    @Kailash
    You must implement paintEvent() in you custom widget like in this example:
    https://gist.github.com/mitchcurtis/233f78d42d62e654f773

    If you want muliple instances of a widget in your main window, use a QGridLayout (or other kind of layouts).

    K 1 Reply Last reply
    2
    • jsulmJ jsulm

      @Kailash said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

      Find_Display_Area(&m_RectangleArea, ui->groupBox_Radar_Display);

      A widget has no proper geometry until it is shown, so accessing geometry in the constructor will not work.

      Where do you call QPainter::begin?

      K Offline
      K Offline
      Kailash
      wrote on last edited by
      #6

      @jsulm said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

      A widget has no proper geometry until it is shown, so accessing geometry in the constructor will not work.

      As you mentioned, obtaining the geometry information is not possible until the MainWindow is fully opened. To validate this, I have continuously printed the geometry within a timer, as demonstrated in the attached code below. I plan to invoke this code within the showEvent method, ensuring it runs only after the MainWindow has been completely opened.

      Where do you call QPainter::begin?

      In the earlier version of the code, I didn't call to QPainter::begin. Now, I attempted to include this call from different locations, such as directly from the MainWindow using the class object and within a test timer. However, I encountered warning messages and observed no display:

      "QPainter::setPen: Painter not active
      QPainter::setRenderHint: Painter must be active to set rendering hints
      QPainter::setBrush: Painter not active"

      1 Reply Last reply
      0
      • M mpergand

        @Kailash
        You must implement paintEvent() in you custom widget like in this example:
        https://gist.github.com/mitchcurtis/233f78d42d62e654f773

        If you want muliple instances of a widget in your main window, use a QGridLayout (or other kind of layouts).

        K Offline
        K Offline
        Kailash
        wrote on last edited by
        #7

        @mpergand said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

        You must implement paintEvent() in you custom widget like in this example:

        We are able to display the radar display in seperate dialog and i feel the refered link is similar to this. But what i need is to integrated multiple display (UI and CPP) in mainwindow UI (for eg : using stacked widget)

        SGaistS 1 Reply Last reply
        0
        • K Kailash

          @mpergand said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

          You must implement paintEvent() in you custom widget like in this example:

          We are able to display the radar display in seperate dialog and i feel the refered link is similar to this. But what i need is to integrated multiple display (UI and CPP) in mainwindow UI (for eg : using stacked widget)

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @Kailash you should do the painting in the paintEvent method of your widget. It will be called as appropriate.

          If your painting is pretty much static, you can also paint on a pixmap in for example the resizeEvent method and then only draw said pixmap in the paintEvent method.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          K 1 Reply Last reply
          1
          • SGaistS SGaist

            @Kailash you should do the painting in the paintEvent method of your widget. It will be called as appropriate.

            If your painting is pretty much static, you can also paint on a pixmap in for example the resizeEvent method and then only draw said pixmap in the paintEvent method.

            K Offline
            K Offline
            Kailash
            wrote on last edited by
            #9

            @SGaist said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

            you should do the painting in the paintEvent method of your widget. It will be called as appropriate.

            SGaist,
            I have included the paintEvent in my widget class. The paintevent is not triggered automatically, hence i tried to trigger the paintEvent using update() but with no luck.

            So kindly suggest a way to call the paintEvent() from the mainwindow or within widget without the use of show() or exec().

            If Show() or exec() is called, it makes the widget popped as a separate dialog, but i want to display the widget in the mainwindow inside a stacked widget.

            jsulmJ 1 Reply Last reply
            0
            • K Kailash

              @SGaist said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

              you should do the painting in the paintEvent method of your widget. It will be called as appropriate.

              SGaist,
              I have included the paintEvent in my widget class. The paintevent is not triggered automatically, hence i tried to trigger the paintEvent using update() but with no luck.

              So kindly suggest a way to call the paintEvent() from the mainwindow or within widget without the use of show() or exec().

              If Show() or exec() is called, it makes the widget popped as a separate dialog, but i want to display the widget in the mainwindow inside a stacked widget.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @Kailash said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

              The paintevent is not triggered automatically

              Then you did something wrong. Please show the code.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              K 1 Reply Last reply
              1
              • jsulmJ jsulm

                @Kailash said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                The paintevent is not triggered automatically

                Then you did something wrong. Please show the code.

                K Offline
                K Offline
                Kailash
                wrote on last edited by Kailash
                #11

                @jsulm said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                Then you did something wrong. Please show the code.

                // Mainwindow
                
                #ifndef MAINWINDOW_H
                #define MAINWINDOW_H
                
                #include <QMainWindow>
                #include <QObject>
                #include <QGroupBox>
                #include "display_radar.h"
                
                QT_BEGIN_NAMESPACE
                namespace Ui { class MainWindow; }
                QT_END_NAMESPACE
                
                class MainWindow : public QMainWindow
                {
                    Q_OBJECT
                
                public:
                    MainWindow(QWidget *parent = nullptr);
                    ~MainWindow();
                    void insert_Radar_Display_in_Stacked_Widget(QWidget *in_pWidget_to_insert_in_StackedWidget);
                    bool m_isDisplayInsertedInStackedWidget;
                
                protected:
                    void showEvent(QShowEvent *event) override;
                
                private:
                    Ui::MainWindow *ui;
                    qreal m_dCircleRadius;
                    Display_Radar *m_obj_Display_Radar;
                };
                #endif // MAINWINDOW_H
                
                
                // CPP
                
                #include "mainwindow.h"
                #include "ui_mainwindow.h"
                #include "Radar_Display_Draw_Headers.h"
                #include <QDebug>
                #include <QPainter>
                #include <QThread>
                
                MainWindow *g_pMainwindow = nullptr;
                MainWindow::MainWindow(QWidget *parent)
                    : QMainWindow(parent)
                    , ui(new Ui::MainWindow)
                {
                    ui->setupUi(this);
                    g_pMainwindow = this;
                    m_obj_Display_Radar = NULL;
                    m_isDisplayInsertedInStackedWidget = false;
                }
                
                MainWindow::~MainWindow()
                {
                    delete ui;
                }
                
                void MainWindow::insert_Radar_Display_in_Stacked_Widget(QWidget *in_pWidget_to_insert_in_StackedWidget)
                {
                    if(in_pWidget_to_insert_in_StackedWidget == NULL)
                    {
                        return;
                    }
                
                    m_isDisplayInsertedInStackedWidget = true;
                
                    ui->stackedWidget_Radar_Display->insertWidget(0, in_pWidget_to_insert_in_StackedWidget);
                    ui->stackedWidget_Radar_Display->setCurrentIndex(0);
                    ui->stackedWidget_Radar_Display->show();
                }
                
                void MainWindow::showEvent(QShowEvent *event)
                {
                    if(m_obj_Display_Radar == NULL)
                    {
                        m_obj_Display_Radar = new Display_Radar(this);
                    }
                
                    m_obj_Display_Radar->Find_Display_Area();
                    m_obj_Display_Radar->Repaint_PaintEvent();
                
                    QWidget::showEvent(event);
                }
                
                // Display Radar
                
                #ifndef DISPLAY_RADAR_H
                #define DISPLAY_RADAR_H
                
                #include <QDialog>
                #include <QObject>
                #include <QGroupBox>
                
                namespace Ui {
                class Display_Radar;
                }
                
                class Display_Radar : public QDialog
                {
                    Q_OBJECT
                
                public:
                    explicit Display_Radar(QWidget *parent = nullptr);
                    ~Display_Radar();
                
                    QPixmap m_Static_Display;
                    QPainter *m_Display_Painter;
                    QRectF m_qrect_Radar_Disp_Area;
                
                    void Draw_Radar_Static_Screen(QRectF *in_p_qRectF_Radar_Display_Area, QPainter *in_p_Painter, double *in_dp_Display_Percentage);
                    void Find_Display_Area();
                    void Repaint_PaintEvent();
                
                public slots:
                    void Display_Radar_Test_Slot();
                
                protected:
                    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
                
                private:
                    Ui::Display_Radar *ui;
                
                    qreal d_Max_ScreenRange, d_RectangleWidth, d_Circle_Radius_percentage;
                    QTimer *m_objDisplayTimer;
                };
                
                #endif // DISPLAY_RADAR_H
                
                // CPP
                
                #include "display_radar.h"
                #include "ui_display_radar.h"
                #include "Radar_Display_Draw_Headers.h"
                #include "mainwindow.h"
                #include <QPainter>
                #include <QDebug>
                #include <QtMath>
                #include <QTimer>
                
                extern MainWindow *g_pMainwindow;
                
                Display_Radar::Display_Radar(QWidget *parent) :
                    QDialog(parent),
                    ui(new Ui::Display_Radar)
                {
                    ui->setupUi(this);
                
                
                    d_Circle_Radius_percentage = RADAR_STATIC_CIRCLE_MAX_RADIUS;
                    d_Max_ScreenRange = RADAR_STATIC_ARC_MAX_RANGE /* 100 */;
                
                    memset(&m_qrect_Radar_Disp_Area, 0, sizeof(m_qrect_Radar_Disp_Area));
                
                    g_pMainwindow->insert_Radar_Display_in_Stacked_Widget(ui->groupBox_Radar_Display);
                
                
                }
                
                Display_Radar::~Display_Radar()
                {
                    delete ui;
                }
                
                void Display_Radar::Draw_Radar_Static_Screen(QRectF *in_p_qRectF_Radar_Display_Area, QPainter *in_p_Painter, double *in_dp_Display_Percentage)
                {
                    qreal d_changedWidth = 0, d_changedHeight = 0;
                    qreal d_X1 = 0, d_Y1 = 0;
                    QColor Brush_Circle_color;
                    QLineF LineF_Angle_DrawLine;
                    QPen QPen_Radar_dotted_line;
                
                    memset(&Brush_Circle_color , 0, sizeof(Brush_Circle_color));
                    memset(&LineF_Angle_DrawLine , 0, sizeof(LineF_Angle_DrawLine));
                
                    Brush_Circle_color.setRgb(0,0,0,200);
                
                    QPen_Radar_dotted_line.setWidth(2);
                    QPen_Radar_dotted_line.setColor(QColor(6, 150, 11, 255));
                    QPen_Radar_dotted_line.setStyle(Qt::DotLine);
                
                    d_changedWidth = ((in_p_qRectF_Radar_Display_Area->width() * (*in_dp_Display_Percentage)) / 100);
                    d_changedHeight = ((in_p_qRectF_Radar_Display_Area->height() * (*in_dp_Display_Percentage)) / 100);
                
                    d_RectangleWidth = d_changedWidth;
                
                    in_p_Painter->setPen(Qt::NoPen);
                    in_p_Painter->setRenderHint(QPainter::Antialiasing);
                    in_p_Painter->setBrush(Brush_Circle_color);
                
                    d_X1 = in_p_qRectF_Radar_Display_Area->x() + (in_p_qRectF_Radar_Display_Area->width() - d_changedWidth) /*/ 2*/;
                    d_Y1 = in_p_qRectF_Radar_Display_Area->y() + (in_p_qRectF_Radar_Display_Area->height() - d_changedHeight)/* / 2*/;
                
                    in_p_Painter->drawPie(d_X1, d_Y1, d_changedWidth, d_changedHeight, 0 * 16, 180 *16);
                }
                
                /* Paint Event is not called */
                void Display_Radar::paintEvent(QPaintEvent *event)
                {
                    Q_UNUSED(event); // handles unused events
                
                    qDebug()<<"Painter is called";
                    QPainter painter(this);
                    Draw_Radar_Static_Screen(&m_qrect_Radar_Disp_Area, &painter, &d_Circle_Radius_percentage);
                }
                
                void Display_Radar::Find_Display_Area()
                {
                    qreal d_x1 = 0.0, d_y1 = 0.0 ,d_x2 = 0.0,d_y2 = 0.0; // coordinates to set the points
                    qreal dCorrection_x = 0, dCorrection_y = 0;
                
                    d_x1 = ui->groupBox_Radar_Display->geometry().topLeft().x() + 25;
                    d_y1 = ui->groupBox_Radar_Display->geometry().topLeft().y() + 35;
                    d_x2 = ui->groupBox_Radar_Display->geometry().bottomRight().x() ;
                    d_y2 = ui->groupBox_Radar_Display->geometry().bottomRight().y() ;
                
                    m_qrect_Radar_Disp_Area.setCoords((d_x1  + dCorrection_x), (d_y1 + dCorrection_y), (d_x2 - dCorrection_x), (d_y2 - dCorrection_y));
                }
                
                void Display_Radar::Repaint_PaintEvent()
                {
                    this->update();
                }
                
                void Display_Radar::Display_Radar_Test_Slot()
                {
                    if(g_pMainwindow->m_isDisplayInsertedInStackedWidget == true)
                    {
                        Repaint_PaintEvent();
                    }
                }
                
                
                jsulmJ 1 Reply Last reply
                0
                • K Kailash

                  @jsulm said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                  Then you did something wrong. Please show the code.

                  // Mainwindow
                  
                  #ifndef MAINWINDOW_H
                  #define MAINWINDOW_H
                  
                  #include <QMainWindow>
                  #include <QObject>
                  #include <QGroupBox>
                  #include "display_radar.h"
                  
                  QT_BEGIN_NAMESPACE
                  namespace Ui { class MainWindow; }
                  QT_END_NAMESPACE
                  
                  class MainWindow : public QMainWindow
                  {
                      Q_OBJECT
                  
                  public:
                      MainWindow(QWidget *parent = nullptr);
                      ~MainWindow();
                      void insert_Radar_Display_in_Stacked_Widget(QWidget *in_pWidget_to_insert_in_StackedWidget);
                      bool m_isDisplayInsertedInStackedWidget;
                  
                  protected:
                      void showEvent(QShowEvent *event) override;
                  
                  private:
                      Ui::MainWindow *ui;
                      qreal m_dCircleRadius;
                      Display_Radar *m_obj_Display_Radar;
                  };
                  #endif // MAINWINDOW_H
                  
                  
                  // CPP
                  
                  #include "mainwindow.h"
                  #include "ui_mainwindow.h"
                  #include "Radar_Display_Draw_Headers.h"
                  #include <QDebug>
                  #include <QPainter>
                  #include <QThread>
                  
                  MainWindow *g_pMainwindow = nullptr;
                  MainWindow::MainWindow(QWidget *parent)
                      : QMainWindow(parent)
                      , ui(new Ui::MainWindow)
                  {
                      ui->setupUi(this);
                      g_pMainwindow = this;
                      m_obj_Display_Radar = NULL;
                      m_isDisplayInsertedInStackedWidget = false;
                  }
                  
                  MainWindow::~MainWindow()
                  {
                      delete ui;
                  }
                  
                  void MainWindow::insert_Radar_Display_in_Stacked_Widget(QWidget *in_pWidget_to_insert_in_StackedWidget)
                  {
                      if(in_pWidget_to_insert_in_StackedWidget == NULL)
                      {
                          return;
                      }
                  
                      m_isDisplayInsertedInStackedWidget = true;
                  
                      ui->stackedWidget_Radar_Display->insertWidget(0, in_pWidget_to_insert_in_StackedWidget);
                      ui->stackedWidget_Radar_Display->setCurrentIndex(0);
                      ui->stackedWidget_Radar_Display->show();
                  }
                  
                  void MainWindow::showEvent(QShowEvent *event)
                  {
                      if(m_obj_Display_Radar == NULL)
                      {
                          m_obj_Display_Radar = new Display_Radar(this);
                      }
                  
                      m_obj_Display_Radar->Find_Display_Area();
                      m_obj_Display_Radar->Repaint_PaintEvent();
                  
                      QWidget::showEvent(event);
                  }
                  
                  // Display Radar
                  
                  #ifndef DISPLAY_RADAR_H
                  #define DISPLAY_RADAR_H
                  
                  #include <QDialog>
                  #include <QObject>
                  #include <QGroupBox>
                  
                  namespace Ui {
                  class Display_Radar;
                  }
                  
                  class Display_Radar : public QDialog
                  {
                      Q_OBJECT
                  
                  public:
                      explicit Display_Radar(QWidget *parent = nullptr);
                      ~Display_Radar();
                  
                      QPixmap m_Static_Display;
                      QPainter *m_Display_Painter;
                      QRectF m_qrect_Radar_Disp_Area;
                  
                      void Draw_Radar_Static_Screen(QRectF *in_p_qRectF_Radar_Display_Area, QPainter *in_p_Painter, double *in_dp_Display_Percentage);
                      void Find_Display_Area();
                      void Repaint_PaintEvent();
                  
                  public slots:
                      void Display_Radar_Test_Slot();
                  
                  protected:
                      void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
                  
                  private:
                      Ui::Display_Radar *ui;
                  
                      qreal d_Max_ScreenRange, d_RectangleWidth, d_Circle_Radius_percentage;
                      QTimer *m_objDisplayTimer;
                  };
                  
                  #endif // DISPLAY_RADAR_H
                  
                  // CPP
                  
                  #include "display_radar.h"
                  #include "ui_display_radar.h"
                  #include "Radar_Display_Draw_Headers.h"
                  #include "mainwindow.h"
                  #include <QPainter>
                  #include <QDebug>
                  #include <QtMath>
                  #include <QTimer>
                  
                  extern MainWindow *g_pMainwindow;
                  
                  Display_Radar::Display_Radar(QWidget *parent) :
                      QDialog(parent),
                      ui(new Ui::Display_Radar)
                  {
                      ui->setupUi(this);
                  
                  
                      d_Circle_Radius_percentage = RADAR_STATIC_CIRCLE_MAX_RADIUS;
                      d_Max_ScreenRange = RADAR_STATIC_ARC_MAX_RANGE /* 100 */;
                  
                      memset(&m_qrect_Radar_Disp_Area, 0, sizeof(m_qrect_Radar_Disp_Area));
                  
                      g_pMainwindow->insert_Radar_Display_in_Stacked_Widget(ui->groupBox_Radar_Display);
                  
                  
                  }
                  
                  Display_Radar::~Display_Radar()
                  {
                      delete ui;
                  }
                  
                  void Display_Radar::Draw_Radar_Static_Screen(QRectF *in_p_qRectF_Radar_Display_Area, QPainter *in_p_Painter, double *in_dp_Display_Percentage)
                  {
                      qreal d_changedWidth = 0, d_changedHeight = 0;
                      qreal d_X1 = 0, d_Y1 = 0;
                      QColor Brush_Circle_color;
                      QLineF LineF_Angle_DrawLine;
                      QPen QPen_Radar_dotted_line;
                  
                      memset(&Brush_Circle_color , 0, sizeof(Brush_Circle_color));
                      memset(&LineF_Angle_DrawLine , 0, sizeof(LineF_Angle_DrawLine));
                  
                      Brush_Circle_color.setRgb(0,0,0,200);
                  
                      QPen_Radar_dotted_line.setWidth(2);
                      QPen_Radar_dotted_line.setColor(QColor(6, 150, 11, 255));
                      QPen_Radar_dotted_line.setStyle(Qt::DotLine);
                  
                      d_changedWidth = ((in_p_qRectF_Radar_Display_Area->width() * (*in_dp_Display_Percentage)) / 100);
                      d_changedHeight = ((in_p_qRectF_Radar_Display_Area->height() * (*in_dp_Display_Percentage)) / 100);
                  
                      d_RectangleWidth = d_changedWidth;
                  
                      in_p_Painter->setPen(Qt::NoPen);
                      in_p_Painter->setRenderHint(QPainter::Antialiasing);
                      in_p_Painter->setBrush(Brush_Circle_color);
                  
                      d_X1 = in_p_qRectF_Radar_Display_Area->x() + (in_p_qRectF_Radar_Display_Area->width() - d_changedWidth) /*/ 2*/;
                      d_Y1 = in_p_qRectF_Radar_Display_Area->y() + (in_p_qRectF_Radar_Display_Area->height() - d_changedHeight)/* / 2*/;
                  
                      in_p_Painter->drawPie(d_X1, d_Y1, d_changedWidth, d_changedHeight, 0 * 16, 180 *16);
                  }
                  
                  /* Paint Event is not called */
                  void Display_Radar::paintEvent(QPaintEvent *event)
                  {
                      Q_UNUSED(event); // handles unused events
                  
                      qDebug()<<"Painter is called";
                      QPainter painter(this);
                      Draw_Radar_Static_Screen(&m_qrect_Radar_Disp_Area, &painter, &d_Circle_Radius_percentage);
                  }
                  
                  void Display_Radar::Find_Display_Area()
                  {
                      qreal d_x1 = 0.0, d_y1 = 0.0 ,d_x2 = 0.0,d_y2 = 0.0; // coordinates to set the points
                      qreal dCorrection_x = 0, dCorrection_y = 0;
                  
                      d_x1 = ui->groupBox_Radar_Display->geometry().topLeft().x() + 25;
                      d_y1 = ui->groupBox_Radar_Display->geometry().topLeft().y() + 35;
                      d_x2 = ui->groupBox_Radar_Display->geometry().bottomRight().x() ;
                      d_y2 = ui->groupBox_Radar_Display->geometry().bottomRight().y() ;
                  
                      m_qrect_Radar_Disp_Area.setCoords((d_x1  + dCorrection_x), (d_y1 + dCorrection_y), (d_x2 - dCorrection_x), (d_y2 - dCorrection_y));
                  }
                  
                  void Display_Radar::Repaint_PaintEvent()
                  {
                      this->update();
                  }
                  
                  void Display_Radar::Display_Radar_Test_Slot()
                  {
                      if(g_pMainwindow->m_isDisplayInsertedInStackedWidget == true)
                      {
                          Repaint_PaintEvent();
                      }
                  }
                  
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @Kailash said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                  qDebug()<<"Painter is called";

                  So, "Painter is called" is never printed?

                  And what is this?!

                  g_pMainwindow->insert_Radar_Display_in_Stacked_Widget(ui->groupBox_Radar_Display);
                  

                  Why is your radar manipulating the main window directly and putting its own UI stuff there?! This is very bad design!

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  K 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Kailash said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                    qDebug()<<"Painter is called";

                    So, "Painter is called" is never printed?

                    And what is this?!

                    g_pMainwindow->insert_Radar_Display_in_Stacked_Widget(ui->groupBox_Radar_Display);
                    

                    Why is your radar manipulating the main window directly and putting its own UI stuff there?! This is very bad design!

                    K Offline
                    K Offline
                    Kailash
                    wrote on last edited by Kailash
                    #13

                    @jsulm said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                    So, "Painter is called" is never printed?

                    Yes it is not printed.

                    Why is your radar manipulating the main window directly and putting its own UI stuff there?! This is very bad design!

                    Not found any other method to call and this is the first time i am using stacked widget. Pls let me the right way to do this

                    SGaistS 1 Reply Last reply
                    0
                    • K Kailash

                      @jsulm said in DISPLAY ISSUE - PROMOTING TO MAINWINDOW:

                      So, "Painter is called" is never printed?

                      Yes it is not printed.

                      Why is your radar manipulating the main window directly and putting its own UI stuff there?! This is very bad design!

                      Not found any other method to call and this is the first time i am using stacked widget. Pls let me the right way to do this

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      Like I already wrote:

                      • Create a QWidget subclass
                      • Implement its paintEvent properly
                      • Set the widget as centralWidget on your QMainWindow

                      Once you have that, you can continue further refinements.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2

                      • Login

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