Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Qt Stylesheets
Qt 6.11 is out! See what's new in the release blog

Qt Stylesheets

Scheduled Pinned Locked Moved Solved German
39 Posts 3 Posters 26.9k Views
  • 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.
  • G Galilio

    Hallo zusammen,

    zu dieses Tutorial habe ich Frage:
    http://thesmithfam.org/blog/2009/09/10/qt-stylesheets-tutorial
    --> Step 3

    Wie kann ich den View (nur Ovalform) von MyLoginForm.ui erstellen.
    Ich möchte keine rechteckform haben und in der mitte dieses Ovalform.

    Ist das machbar?

    danke

    ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #2

    @Galilio Hi! Ich hab nicht verstanden. Was willst du machen?

    1 Reply Last reply
    0
    • G Galilio

      Hallo zusammen,

      zu dieses Tutorial habe ich Frage:
      http://thesmithfam.org/blog/2009/09/10/qt-stylesheets-tutorial
      --> Step 3

      Wie kann ich den View (nur Ovalform) von MyLoginForm.ui erstellen.
      Ich möchte keine rechteckform haben und in der mitte dieses Ovalform.

      Ist das machbar?

      danke

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #3

      @Galilio
      abgsehen davon dass ich auch nicht 100%ig vertsanden habe was die Frage genau ist, versuche ich es trotzdem :)

      Ich nehme an du willst quasi ein "rundes" Fenster haben? Nur das Oval als Fenster?

      1. Auf dem Fenster (Top-Levle widget) musst du die windowFlags auf Qt::CustomizeWindowHint | Qt::FramelessWindowHint
      2. und auch ein widgetAttribute auf Qt::WA_TranslucentBackground setzen
      3. möglich dass man auch noch die Hintergrundfarbe auf transparent setzen muss (z.B. via CSS)

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Galilio
        wrote on last edited by
        #4

        Hi raven,

        danke es ist genau was ich brauche.

        Ich habe dein Vorschlag ausprobiert, aber es hat aucht nicht gebracht.
        Anbei einen Codeabschnitt:

        int main(int argc, char *argv[])
        {
        	Qt::CustomizeWindowHint | Qt::FramelessWindowHint;
        	Qt::WA_TranslucentBackground;
        	QApplication a(argc, argv);
        	MyApplication w;
        	w.show();
        	return a.exec();
        }
        

        Vielleicht verstehe ich das falsch :-(
        danke

        raven-worxR 1 Reply Last reply
        0
        • G Galilio

          Hi raven,

          danke es ist genau was ich brauche.

          Ich habe dein Vorschlag ausprobiert, aber es hat aucht nicht gebracht.
          Anbei einen Codeabschnitt:

          int main(int argc, char *argv[])
          {
          	Qt::CustomizeWindowHint | Qt::FramelessWindowHint;
          	Qt::WA_TranslucentBackground;
          	QApplication a(argc, argv);
          	MyApplication w;
          	w.show();
          	return a.exec();
          }
          

          Vielleicht verstehe ich das falsch :-(
          danke

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #5

          @Galilio said in Qt Stylesheets:

          Vielleicht verstehe ich das falsch :-(

          ja ;)

          Die window flags musst du natürlich auf eine widget Instanz setzen.

          widget->setWindowFlags( Qt::CustomizeWindowHint | Qt::FramelessWindowHint );
          widget->setAttribute( Qt::WA_TranslucentBackground );
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Galilio
            wrote on last edited by
            #6

            erste mal vielen vielen dank.
            Es funktioniert.
            Allerdings mit einen neben Effekt. Ich kann die Application nicht mehr mit der Maus bewegen.

            raven-worxR 1 Reply Last reply
            0
            • G Galilio

              erste mal vielen vielen dank.
              Es funktioniert.
              Allerdings mit einen neben Effekt. Ich kann die Application nicht mehr mit der Maus bewegen.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #7

              @Galilio said in Qt Stylesheets:

              Ich kann die Application nicht mehr mit der Maus bewegen.

              ja klar.
              Wie hast du dir vorgestellt das Fenster zu bewegen?

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              G 1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #8

                Du kannst die mouse event handler überschreiben, um das Fenster wieder beweglich zu machen.

                1 Reply Last reply
                0
                • raven-worxR raven-worx

                  @Galilio said in Qt Stylesheets:

                  Ich kann die Application nicht mehr mit der Maus bewegen.

                  ja klar.
                  Wie hast du dir vorgestellt das Fenster zu bewegen?

                  G Offline
                  G Offline
                  Galilio
                  wrote on last edited by
                  #9

                  @raven-worx

                  Ich dachte, dass ich das Fenster mit der Maus bewegen kann.

                  raven-worxR 1 Reply Last reply
                  0
                  • G Galilio

                    @raven-worx

                    Ich dachte, dass ich das Fenster mit der Maus bewegen kann.

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by raven-worx
                    #10

                    @Galilio
                    ja, aber wie geanu?
                    Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

                    // in .h
                    QPoint hotSpot;
                    
                    // in .cpp
                    void MyWidget::mousePressEvent( QMouseEvent* event )
                    {
                         if( event->button() == Qt::LeftButton )
                         {
                                 hotSpot = this->mapFromGlobal(event->globalPos());
                                 event->accept();
                                 return;
                         }
                         BaseClass::mousePressEvent( event );
                    }
                    
                    void MyWidget::mouseMoveEvent( QMouseEvent* event )
                    {
                          if( hotSpot.isValid() )
                          {
                                this->move( event->globalPos() + hotSpot );
                                event->accept();
                                return;
                          }
                          BaseClass::mouseMoveEvent( event );
                    }
                    
                    void MyWidget::mouseReleaseEvent( QMouseEvent* event )
                    {
                         if( event->button() == Qt::LeftButton )
                         {
                                 hotSpot = QPoint();
                                 event->accept();
                                 return;
                          }
                         BaseClass::mousePressEvent( event );
                    }
                    

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    ? G 2 Replies Last reply
                    0
                    • raven-worxR raven-worx

                      @Galilio
                      ja, aber wie geanu?
                      Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

                      // in .h
                      QPoint hotSpot;
                      
                      // in .cpp
                      void MyWidget::mousePressEvent( QMouseEvent* event )
                      {
                           if( event->button() == Qt::LeftButton )
                           {
                                   hotSpot = this->mapFromGlobal(event->globalPos());
                                   event->accept();
                                   return;
                           }
                           BaseClass::mousePressEvent( event );
                      }
                      
                      void MyWidget::mouseMoveEvent( QMouseEvent* event )
                      {
                            if( hotSpot.isValid() )
                            {
                                  this->move( event->globalPos() + hotSpot );
                                  event->accept();
                                  return;
                            }
                            BaseClass::mouseMoveEvent( event );
                      }
                      
                      void MyWidget::mouseReleaseEvent( QMouseEvent* event )
                      {
                           if( event->button() == Qt::LeftButton )
                           {
                                   hotSpot = QPoint();
                                   event->accept();
                                   return;
                            }
                           BaseClass::mousePressEvent( event );
                      }
                      
                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      @raven-worx Hängt glaub ich auch vom Desktop-System ab: Unter KDE braucht man, um Fenster zu verschieben, ja nicht unbedingt mit der Maus an der window title bar herumzuziehen; da kann man auch Alt + <linke Maustaste gedrückt halten> direkt ins Fenster machen und dann verschieben.

                      1 Reply Last reply
                      0
                      • raven-worxR raven-worx

                        @Galilio
                        ja, aber wie geanu?
                        Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

                        // in .h
                        QPoint hotSpot;
                        
                        // in .cpp
                        void MyWidget::mousePressEvent( QMouseEvent* event )
                        {
                             if( event->button() == Qt::LeftButton )
                             {
                                     hotSpot = this->mapFromGlobal(event->globalPos());
                                     event->accept();
                                     return;
                             }
                             BaseClass::mousePressEvent( event );
                        }
                        
                        void MyWidget::mouseMoveEvent( QMouseEvent* event )
                        {
                              if( hotSpot.isValid() )
                              {
                                    this->move( event->globalPos() + hotSpot );
                                    event->accept();
                                    return;
                              }
                              BaseClass::mouseMoveEvent( event );
                        }
                        
                        void MyWidget::mouseReleaseEvent( QMouseEvent* event )
                        {
                             if( event->button() == Qt::LeftButton )
                             {
                                     hotSpot = QPoint();
                                     event->accept();
                                     return;
                              }
                             BaseClass::mousePressEvent( event );
                        }
                        
                        G Offline
                        G Offline
                        Galilio
                        wrote on last edited by
                        #12

                        @raven-worx said in Qt Stylesheets:

                        // in .h
                        QPoint hotSpot;

                        // in .cpp
                        void MyWidget::mousePressEvent( QMouseEvent* event )
                        {
                        if( event->button() == Qt::LeftButton )
                        {
                        hotSpot = this->mapFromGlobal(event->globalPos());
                        event->accept();
                        return;
                        }
                        BaseClass::mousePressEvent( event );
                        }

                        void MyWidget::mouseMoveEvent( QMouseEvent* event )
                        {
                        if( hotSpot.isValid() )
                        {
                        this->move( event->globalPos() + hotSpot );
                        event->accept();
                        return;
                        }
                        BaseClass::mouseMoveEvent( event );
                        }

                        void MyWidget::mouseReleaseEvent( QMouseEvent* event )
                        {
                        if( event->button() == Qt::LeftButton )
                        {
                        hotSpot = QPoint();
                        event->accept();
                        return;
                        }
                        BaseClass::mousePressEvent( event );
                        }

                        vielen dank
                        Es ist genau was ich brauche:
                        Hier meine kleine Ergänzung:

                        // in .h
                        QPoint hotSpot;
                        
                        // in .cpp
                        void MyWidget::mousePressEvent( QMouseEvent* event )
                        {
                             if( event->button() == Qt::LeftButton )
                             {
                                     hotSpot = this->mapFromGlobal(event->globalPos());
                                     event->accept();
                                     return;
                             }
                        	if (event->button() == Qt::RightButton)
                        	{
                        		hotSpot = this->mapFromGlobal(event->globalPos());
                        		event->accept();
                        		return;
                        	}
                             BaseClass::mousePressEvent( event );
                        }
                        
                        void MyWidget::mouseMoveEvent( QMouseEvent* event )
                        {
                            QPoint point = event->pos() - hotSpot;
                        	if (point.manhattanLength()>0)
                                    this->move( event->globalPos() - hotSpot );
                                    event->accept();
                                    return;
                              }
                              BaseClass::mouseMoveEvent( event );
                        }
                        
                        void MyWidget::mouseReleaseEvent( QMouseEvent* event )
                        {
                             if( event->button() == Qt::LeftButton )
                             {
                                     hotSpot = QPoint();
                                     event->accept();
                                     return;
                              }
                             BaseClass::mousePressEvent( event );
                        }
                        

                        sonst funktioniert alles
                        nochmal danke

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          Galilio
                          wrote on last edited by
                          #13

                          Guten morgen Zusammen,

                          eine Frage zu dem Thema.

                          ich habe einen Dialog in MyApplication.
                          In dieses Dialog möchte ich auch das gleiche Design wie MyApplication
                          Dieses Dialog wird so gerufen:

                          void MyApplication::showAboutApplication()
                          {
                          AboutDialog *dialog = new AboutDiaolog(this);
                          dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                          dialog->setAttribute(Qt::WA_TranslucentBackground);
                          dialog->exec();
                          delete dialog;
                          
                          }
                          

                          Das komisch daran ist, dass das Dialog abgeschnitten wird.
                          was ist daran falsch?

                          danke in voraus

                          raven-worxR 1 Reply Last reply
                          0
                          • G Galilio

                            Guten morgen Zusammen,

                            eine Frage zu dem Thema.

                            ich habe einen Dialog in MyApplication.
                            In dieses Dialog möchte ich auch das gleiche Design wie MyApplication
                            Dieses Dialog wird so gerufen:

                            void MyApplication::showAboutApplication()
                            {
                            AboutDialog *dialog = new AboutDiaolog(this);
                            dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                            dialog->setAttribute(Qt::WA_TranslucentBackground);
                            dialog->exec();
                            delete dialog;
                            
                            }
                            

                            Das komisch daran ist, dass das Dialog abgeschnitten wird.
                            was ist daran falsch?

                            danke in voraus

                            raven-worxR Offline
                            raven-worxR Offline
                            raven-worx
                            Moderators
                            wrote on last edited by
                            #14

                            @Galilio
                            ist ein Layout auf dem Dialog gesetzt? Wenn ja, dann:

                            void MyApplication::showAboutApplication()
                            {
                            AboutDialog *dialog = new AboutDiaolog(this);
                            dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                            dialog->setAttribute(Qt::WA_TranslucentBackground);
                            dialog->resize( dialog->sizeHint() );  // <<<<<<<<<<<<
                            dialog->exec();
                            delete dialog;
                            }
                            

                            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                            If you have a question please use the forum so others can benefit from the solution in the future

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              Galilio
                              wrote on last edited by
                              #15

                              Hallo,

                              es passiert nichts.

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                Galilio
                                wrote on last edited by
                                #16

                                Mit passiert nichts meine ich: Dialog wird nicht mal gezeigt

                                raven-worxR 1 Reply Last reply
                                0
                                • G Galilio

                                  Mit passiert nichts meine ich: Dialog wird nicht mal gezeigt

                                  raven-worxR Offline
                                  raven-worxR Offline
                                  raven-worx
                                  Moderators
                                  wrote on last edited by
                                  #17

                                  @Galilio
                                  du hast geschrieben

                                  Das komisch daran ist, dass das Dialog abgeschnitten wird.

                                  ???

                                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                  If you have a question please use the forum so others can benefit from the solution in the future

                                  G 1 Reply Last reply
                                  0
                                  • raven-worxR raven-worx

                                    @Galilio
                                    du hast geschrieben

                                    Das komisch daran ist, dass das Dialog abgeschnitten wird.

                                    ???

                                    G Offline
                                    G Offline
                                    Galilio
                                    wrote on last edited by
                                    #18

                                    @raven-worx

                                    1. Ohne das:
                                    dialog->resize(dialog->sizeHint());
                                    

                                    Dialog ist abgeschnitten.

                                    1. Mit:
                                    dialog->resize(dialog->sizeHint());
                                    

                                    wird nichts gezeigt

                                    raven-worxR 1 Reply Last reply
                                    0
                                    • G Galilio

                                      @raven-worx

                                      1. Ohne das:
                                      dialog->resize(dialog->sizeHint());
                                      

                                      Dialog ist abgeschnitten.

                                      1. Mit:
                                      dialog->resize(dialog->sizeHint());
                                      

                                      wird nichts gezeigt

                                      raven-worxR Offline
                                      raven-worxR Offline
                                      raven-worx
                                      Moderators
                                      wrote on last edited by
                                      #19

                                      @Galilio
                                      dann verwendest du kein Layout in dialog?

                                      Mein Vorschlag funktioniert nur wenn du ein Layout verwendest (oder sizeHint() überladen hast). Ohne Layout musst du den Dialog selbst resizen bis es passt.

                                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                      If you have a question please use the forum so others can benefit from the solution in the future

                                      G 1 Reply Last reply
                                      0
                                      • raven-worxR raven-worx

                                        @Galilio
                                        dann verwendest du kein Layout in dialog?

                                        Mein Vorschlag funktioniert nur wenn du ein Layout verwendest (oder sizeHint() überladen hast). Ohne Layout musst du den Dialog selbst resizen bis es passt.

                                        G Offline
                                        G Offline
                                        Galilio
                                        wrote on last edited by
                                        #20

                                        @raven-worx

                                        doch ich verwende einen Layout und zwar den Grid Layout.

                                        raven-worxR 1 Reply Last reply
                                        0
                                        • G Galilio

                                          @raven-worx

                                          doch ich verwende einen Layout und zwar den Grid Layout.

                                          raven-worxR Offline
                                          raven-worxR Offline
                                          raven-worx
                                          Moderators
                                          wrote on last edited by
                                          #21

                                          @Galilio
                                          was gibt folgendes zurück?

                                          qDebug() << dialog->layout();
                                          

                                          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                          If you have a question please use the forum so others can benefit from the solution in the future

                                          G 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