hello:
I want to change the title bar and border of a QMainWindow. for example: i want to paint a picture on the title bar .But QPainter can not paint any thing on title bar. if somebody can help me? how can i do?
hello:
I want to change the title bar and border of a QMainWindow. for example: i want to paint a picture on the title bar .But QPainter can not paint any thing on title bar. if somebody can help me? how can i do?
Last edited by wygggyxtf; 22nd June 2007 at 09:29.
I have inplmented a cuntomized title bar by removing the window decorations, and using my own widget as a titlebar.
I don't think it is possible to actually change the title bar it self, but maybe someone else knows better.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
yes, I have tried this method,but some task trouble me. without real title bar and border, how can i move and resize the QMainWindow with mouse. when i move my mouse to the edge of the QMainwindow, the shape of mouse didn't change to double-arrowhead, so i can not resie the QMainWindow. please tell me , how did you resove the trouble. had better , put up your code to me. please!
You have to implement it your self of coucrse (that is what I did).without real title bar and border, how can i move and resize the QMainWindow with mouse.when i move my mouse to the edge of the QMainwindow, the shape of mouse didn't change to double-arrowhead, so i can not resie the QMainWindow.
Ah.. sorry, not at the moment, no time to look for it (I am at work). (maybe tonight when I get home)please tell me , how did you resove the trouble. had better , put up your code to me. please!
But where is the probem?
You just catch the mouse events, and in them do the moving and resizing, where is the problem?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
The probem is : I can not cath some mouse events, for example: i can not catch mouse move event, although qt have a mouseMoveEvent() slot, but this is be called only when mouse move over the QMainwindow and a mouse key is pressed. if no mouse is pressed, this function is will not be called.
on the other hand, i do not know how to caculate the size of QMainwindow.
please excuse me,I am new to qt, i know only a few qt knowledge. if OK ,please put up your code to me when you are free.
setMouseTracking(true) should do the trick.
With this, MainWindow will receive mouse events even if no buttons are being pressed.
this is getting to specific.
We need to see ALL the relevant code.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
this->setMouseTracking(true);
Q3DockWindow * myDockWidget=new Q3DockWindow(this);
QLabel * myTitle = new QLabel(myDockWidget);
myTitle->setText("hello this is my Title bar");
myDockWidget->setWidget(myTitle);
this->addDockWindow(myDockWidget,Qt:ockTop);
this->moveDockWindow(myDockWidget,Qt:ockTop);
QTabWidget * myTb = new QTabWidget(this);
myPixMap.loadFromData(contact_png,sizeof(contact_p ng),"PNG");
QIcon myContactIcon(myPixMap);
myTb->addTab(cvlist,myContactIcon,NULL);
myPixMap.loadFromData(treasure_png,sizeof(treasure _png),"PNG");
QIcon myTreasureIcon(myPixMap);
QAxWidget * object = new QAxWidget("8856F961-340A-11D0-A96B-00C04FD705A2");
object->dynamicCall("Navigate(const QString&)",treasureWebSite);
myTb->addTab(object,myTreasureIcon,NULL);
myPixMap.loadFromData(friend_png,sizeof(friend_png ),"PNG");
QIcon myFriendIcon(myPixMap);
QAxWidget * object1 = new QAxWidget("8856F961-340A-11D0-A96B-00C04FD705A2");
object1->dynamicCall("Navigate(const QString&)",friendWebSite);
myTb->addTab(object1,myFriendIcon,NULL);
myTb->setIconSize(QSize(18,20));
myTb->setTabPosition ( QTabWidget::West);
myUserInfoButton.setIcon(PsiIconset::instance()->statusPtr(STATUS_OFFLINE)->pixmap());
myUserInfoButton.setText(" ");
d->vb_main->addWidget(&myUserInfoButton);
d->vb_main->addWidget(myTb);
this is the relevant code, please check up, if some thing wrong with the code!
and the mouseMoveEvent()?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
void MainWin::mouseMoveEvent ( QMouseEvent * event ){
if(this->hasMouseTracking()){
QMessageBox myMB1;
myMB1.setText("hasMouseTracking");
myMB1.exec();
}else{
QMessageBox myMB1;
myMB1.setText("has no hasMouseTracking");
myMB1.exec();
}
return;
}
this is mouseMoveEvent function!
and what is the behaviour? are you getting no message box at all?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
hmm... strange.
I can't explain that behaviour from what I see...
EDIT:
Wait, this is a main window right?
So it might be that you have to set the mouse tracking on each element of the main widnow...
What do you have on your main window when you run this?
Last edited by high_flyer; 22nd June 2007 at 11:55.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
wygggyxtf (23rd June 2007)
I have resove the trouble, above the code i have put up, there is a paragraph:
QWidget *center = new QWidget (this, "Central widget");
setCentralWidget ( center );
d->vb_main = new QVBoxLayout(center);
cvlist = new ContactView(center);
now i add a sentence:
center->setMouseTracking(true);
that's OK!
please put up your code that you customize QMainWindow to me! thanks!
Try create message box
QMessageBox *myMB1 = new QMessageBox(...);
myMB1->show(); (exec())
or change something on your widget to see work mousemove or not!
example
QLabel *label;
in your constructor
label = new QLabel ("ddd");
label->setGeometry(...);
and in mouseevent
label->setCaption("Work");
Bookmarks