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. [SOLVED] Inserting Paintevent into own Widget
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Inserting Paintevent into own Widget

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.8k 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.
  • M Offline
    M Offline
    MrNoway
    wrote on last edited by
    #1

    Hey, this driving me crazy,

    how can I insert a paint event into a custom widget

    if this is my mini paintevent

    @void Lines::paintEvent(QPaintEvent *e)
    {

    QPainter qp(this);
    QPen pen (Qt::blue, 2, Qt::SolidLine);
    qp.setPen(pen);
    qp.drawRect(100,100,100,100);}@

    here my widget

    @ QWidget *widget1;
    widget1 = new QWidget;
    widget1->show();@

    € or maybe you could tell me, how to insert buttons/labels into a paintevent window.
    this would also work for my problem.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      poor_robert
      wrote on last edited by
      #2

      Can we see the rest of Your code?. And can You can explain what exactly do You want to achieve?

      In my opinion You should read some Qt tutorial/examples before starting Your adventure with Qt.

      poor_Robert

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MrNoway
        wrote on last edited by
        #3

        bq. Your adventure with Qt.bq.

        hahaha, that sounds sweet,

        I uploaded the whole project here,
        http://www.mediafire.com/?gubgnqk6281j8l8

        and here is a screenshot what it does
        http://img690.imageshack.us/img690/6371/89805244.jpg

        it draws a sinus with dots, after finishing it restarts the sinus curve,
        and line connects the new and old sinus

        O.O

        I need now some buttons, labels, slots to control/change the curve.
        But I want the buttons to be in the same widget/window as the curve

        1 Reply Last reply
        0
        • P Offline
          P Offline
          poor_robert
          wrote on last edited by
          #4

          Hmmm,

          If I were You I would just add some QChecBoxes, QSpinBoxes and other Qt's stock widgets. I would place those sub-widgets to the same layout as Your plot, then I would connect their signals to my plot's slots to do desired things.

          But, if You want to have Your own buttons, labels, etc maybe You should think about createing Your own "Plot control widgets". In such case You should derive from QWidget and override methods like mousePressEvent, paintEvent etc to achieve what You want.

          poor_Robert

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MrNoway
            wrote on last edited by
            #5

            No, it can be done so much easier,
            all you have to do is to create a MainWindow,
            the paintevent is automatically drawn inside it,
            and wherever you put your buttons and labels, they will be there.

            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