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

Qt Stylesheets

Scheduled Pinned Locked Moved Solved German
39 Posts 3 Posters 33.6k 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.
  • 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
                      • raven-worxR raven-worx

                        @Galilio
                        was gibt folgendes zurück?

                        qDebug() << dialog->layout();
                        
                        G Offline
                        G Offline
                        Galilio
                        wrote on last edited by
                        #22

                        @raven-worx

                        QGridLayout(0x142624d8, name = "gridLayout_2")

                        raven-worxR 1 Reply Last reply
                        0
                        • G Galilio

                          @raven-worx

                          QGridLayout(0x142624d8, name = "gridLayout_2")

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

                          @Galilio
                          hmm...strange.
                          Dann dürfte irgendein widget in der Hierachie nicht sizeHint() implementiert haben, oder eine maximum size gesetzt sein? ... kA
                          Bleibt wohl nur das "händische resizen".

                          --- 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
                            hmm...strange.
                            Dann dürfte irgendein widget in der Hierachie nicht sizeHint() implementiert haben, oder eine maximum size gesetzt sein? ... kA
                            Bleibt wohl nur das "händische resizen".

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

                            @raven-worx
                            jetzt wenn ich das anwende:

                            	AboutDialog *dialog = new AboutDialog(this);
                            	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                            	dialog->setAttribute(Qt::WA_TranslucentBackground);
                            	dialog->resize(dialog->sizeHint());
                            

                            oder

                            	AboutDialog *dialog = new AboutDialog(this);
                            	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                            	dialog->setAttribute(Qt::WA_TranslucentBackground);
                            

                            --> Dialog wird gar nicht gezeigt
                            Ich setze auch nirgend eine Minimum bzw. Maximum

                            raven-worxR 1 Reply Last reply
                            0
                            • G Galilio

                              @raven-worx
                              jetzt wenn ich das anwende:

                              	AboutDialog *dialog = new AboutDialog(this);
                              	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                              	dialog->setAttribute(Qt::WA_TranslucentBackground);
                              	dialog->resize(dialog->sizeHint());
                              

                              oder

                              	AboutDialog *dialog = new AboutDialog(this);
                              	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                              	dialog->setAttribute(Qt::WA_TranslucentBackground);
                              

                              --> Dialog wird gar nicht gezeigt
                              Ich setze auch nirgend eine Minimum bzw. Maximum

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

                              @Galilio said in Qt Stylesheets:

                              dialog->resize(dialog->sizeHint());

                              dialog->resize( QSize(x,y) ); //<< passende size
                              

                              --- 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 said in Qt Stylesheets:

                                dialog->resize(dialog->sizeHint());

                                dialog->resize( QSize(x,y) ); //<< passende size
                                
                                G Offline
                                G Offline
                                Galilio
                                wrote on last edited by
                                #26

                                @raven-worx
                                Dialog wird trotzdem nicht gezeigt

                                raven-worxR 1 Reply Last reply
                                0
                                • G Galilio

                                  @raven-worx
                                  Dialog wird trotzdem nicht gezeigt

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

                                  @Galilio
                                  also sobald dein Dialog resized wird, wird er nicht mehr gezeigt?!
                                  Dann ist irgendwas mit deiner Implementierung nicht in Ordnung.

                                  --- 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
                                    also sobald dein Dialog resized wird, wird er nicht mehr gezeigt?!
                                    Dann ist irgendwas mit deiner Implementierung nicht in Ordnung.

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

                                    @raven-worx
                                    Mit resize oder ohne
                                    Dialog wird nicht gezeigt.
                                    Wenn ich das ganze auskommentiere :

                                    	AboutDialog *dialog = new AboutDialog(this);
                                    	//dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                    	//dialog->setAttribute(Qt::WA_TranslucentBackground);
                                    	//dialog->resize(QSize(250,260));
                                    	qDebug() << dialog->layout();
                                    	dialog->exec();
                                    	delete dialog;
                                    

                                    --> Dialog wird gezeigt

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

                                      @Galilio
                                      also sobald dein Dialog resized wird, wird er nicht mehr gezeigt?!
                                      Dann ist irgendwas mit deiner Implementierung nicht in Ordnung.

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

                                      @raven-worx
                                      Warum sollte in der Implementierung was falsch sein.
                                      Ich tue nicht anders als das Objeckt zu erzeugen mehr nicht.

                                      1 Reply Last reply
                                      0
                                      • G Galilio

                                        @raven-worx
                                        Mit resize oder ohne
                                        Dialog wird nicht gezeigt.
                                        Wenn ich das ganze auskommentiere :

                                        	AboutDialog *dialog = new AboutDialog(this);
                                        	//dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                        	//dialog->setAttribute(Qt::WA_TranslucentBackground);
                                        	//dialog->resize(QSize(250,260));
                                        	qDebug() << dialog->layout();
                                        	dialog->exec();
                                        	delete dialog;
                                        

                                        --> Dialog wird gezeigt

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

                                        @Galilio said in Qt Stylesheets:

                                        Mit resize oder ohne
                                        Dialog wird nicht gezeigt.
                                        Wenn ich das ganze auskommentiere :

                                        liegt ws nur an der Zeile mit Qt::WA_TranslucentBackground?? Kannst du das mal ausprobieren.

                                        Läuft irgendeine OpenGL Anwendung nebenbei?

                                        --- 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 said in Qt Stylesheets:

                                          Mit resize oder ohne
                                          Dialog wird nicht gezeigt.
                                          Wenn ich das ganze auskommentiere :

                                          liegt ws nur an der Zeile mit Qt::WA_TranslucentBackground?? Kannst du das mal ausprobieren.

                                          Läuft irgendeine OpenGL Anwendung nebenbei?

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

                                          @raven-worx said in Qt Stylesheets:

                                          liegt ws nur an der Zeile mit Qt::WA_TranslucentBackground??
                                          @ Was meinst du bitte damit?
                                          Läuft irgendeine OpenGL Anwendung nebenbei?
                                          @ Nein

                                          raven-worxR 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
                                          • Unsolved