qx.ui.form.Button()如何实现标签对齐

时间:2017-10-12 02:34:34

标签: qooxdoo

enter image description here

var button1 = new qx.ui.form.Button("Button", "http://www.qooxdoo.org/current/widgetbrowser/resource/qx/icon/Tango/48/devices/camera-photo.png");
button1.setIconPosition("bottom");
button1.setWidth(200);

this.getRoot().add(button1,{ top: 20, left: 20 });

游乐场:tinyurl.com/y9rlxpxt

如何实现图中所示的效果,标签左对齐,图标中心?

2 个答案:

答案 0 :(得分:0)

标签和图标的定位由qx.ui.layout.Atom类处理,虽然它允许自定义图标的位置,但文本会自动定位。

目前,Qooxdoo已经没有简单的方法可以实现您的目标 - 但是,解决问题的方法是查看qx.ui.layout.Atom并编写您自己的版本 - 这将给予您可以完全控制图像和图标的定位方式。

编写自定义布局后,只需button1.setLayout(new mypackage.MyCustomAtomLayout());

即可将其应用于每个按钮

答案 1 :(得分:0)

您可以使用atom的子控件。您的问题的解决方案是:

#define SOCKET_PATH  "/tmp/websock"
int main()

    {
        int sockfd;
        int len;
        struct sockaddr_un address;
        int result;
        char ch[5] = "Start";


        /* -AF_UNIX is a UNIX internal socket, created on the filesystem.
         * -SOCK_STREAM is a reliable, sequenced, connection-based two-way byte stream
         *  (INET equivalent is TCP) */

        sockfd = socket(AF_UNIX, SOCK_STREAM, 0);


        /* -sun_family - specifies type (domain) of socket
         * -sun_path - socket path location (on filesystem) */
        address.sun_family = AF_UNIX;
        strcpy(address.sun_path, SOCKET_PATH);
        len = sizeof(address);


        /* request connection from the server, connecting socket to server with specified address
         * 'len' is the length of the address */
        result = connect(sockfd, (struct sockaddr *)&address, len);


        /* exit with error if connection is not successful */
        if(result == -1) {
            perror("oops: client1");
            exit(1);
        }

        printf("Connected");
        /* otherwise write data to server and obtain response */
        write(sockfd, ch, 5);
        read(sockfd, &ch, 5);
        printf("char from server: %s\n", ch);
        close(sockfd);

        exit(0);
    }