2012-04-05 3 views
2

textFormat을 이미 Qt::RichText으로 설정했지만 링크를 클릭 할 수 없습니다.링크가있는 QMessageBox를 클릭 할 수 없습니다.

QMessageBox msgBox(this); 
msgBox.setWindowTitle(QApplication::applicationName() 
         + " $VER " + QApplication::applicationVersion()); 
msgBox.setTextFormat(Qt::RichText); //this is what makes the links clickable 
msgBox.setText("<a href=\"google.com\">Google</a>"); 
msgBox.setStandardButtons(QMessageBox::Ok); 
msgBox.exec(); 

모든 솔루션? Qt 4.7에서 작동하지 않는 것으로 확인되었습니다.

+1

어떨까요 : ""Google "'? – Anonymous

+0

@Anonymous는 작동하지 않습니다 .. 왜 그런지 모르겠지만 리눅스에서 xdg-open을 호출해야합니다. – daisy

+0

콘솔에 디버그 출력이 있습니까? 단순한 독립형 코드에서도 마찬가지입니까? 데스크탑 환경의 파일 열기 애플리케이션 ('gvfs-open','kde-open' 등)이 있습니까? – Anonymous

답변

2

당신의 HTML을 수정해야하지만 그것은 Qt 4.7.4에서 작동합니다. 최소 예 :이 하나를 사용하는 경우

#include <QApplication> 
#include <QMessageBox> 

int main(int argc, char *argv[]) 
{ 
    QApplication app(argc, argv); 

    QMessageBox msgBox; 
    msgBox.setTextFormat(Qt::RichText); //this is what makes the links clickable 
    msgBox.setText("<a href='http://google.com/'>Google</a>"); 
    msgBox.setStandardButtons(QMessageBox::Ok); 
    msgBox.exec(); 
    return app.exec(); 
} 

은 브라우저 탭이 열려지고 있으며, 다음과 같은 메시지가 내 콘솔에 끝 : 내가 사용하는 경우

Created new window in existing browser session. 

당신의 msgBox.setText 내가 얻을 오류 :

gvfs-open: file:///tmp/b/google.com: error opening location: Error stating file '/tmp/b/google.com': No such file or directory 
+0

당신은 리눅스에 있습니까? 그 태그를 추가하는 것을 잊었습니다 ... – daisy

+0

제공된 최소한의 예제를 사용해 보셨습니까? 링크를 클릭 할 수 있습니까? 어떤 일이 생겼습니까? 콘솔에 기록 된 내용 (예 : '기존 브라우저 세션에서 새 창 만들기')? – Anonymous

관련 문제